I have to make a program to sort arrays, but in the process of wanting to try and test some basic logic for my program, I found that I got an error on visual studio saying "expected an identifier" whenever I try to call the class constructors. Im still fairly new to c++ and took a year off so im totally lost.
Ive made sure I have my #define and #ifndef, so im not sure as to what else to try.
// This is the header file//
#ifndef LAB2_H
#define LAB2_H
using namespace std;
class SortedArray {
private:
int capacity;
int size;
int* arr;
public:
SortedArray(int cap = 10);
~SortedArray();
int setCapacity(int cap);
int getCapacity();
int setSize(int siz);
int getSize();
#endif
// This is the .cpp file for my constructors//
#include "Lab2.h"
#include <iostream>
SortedArray::SortedArray(int cap) {
setCapacity(cap);
}
SortedArray::~SortedArray() {}
int SortedArray::setCapacity(int cap) {
capacity = cap;
}
int SortedArray::getCapacity() {
return capacity;
}
int SortedArray::setSize(int siz) {
size = siz;
}
int SortedArray::getSize() {
return size;
// This is my main function file//
#include "Lab2.h"
#include <iostream>
using namespace std;
int x = 0;
int main() {
int cap = 0;
SortedArray.getCapacity(); // I get the error on this line//
}
I expect to just get a running function that can compile The error message is "expected an identifier"