[Solved] ‘ ‘ was not declared in this scope [closed]


If you want to implement the dynamic array management within a class, you need to qualify your method implementations with the class name.

dynamicArray.cpp

int * dynamicArray::array_constructor(int *  &intPtr, int &size ){
    if(intPtr != NULL){
    // ...

other member functions the same thing.

However, you don’t really use your class in a class-like way at all. So you could consider turning your class into a namespace and implement the functions there (or in global scope):

dynamicArray.h

namespace dynamicArray // optional namespace
{
    int * array_constructor(int *  &intPtr, int &size );
    int * array_resize(int * &intPtr, int& currSize, int& newSize);
    void array_destructor(int * &intPtr);
    void array_set(int* &intPtr, int &size);
}

dynamicArray.cpp

namespace dynamicArray // optional namespace
{
    int * array_constructor(int *  &intPtr, int &size ){
        if(intPtr != NULL){

    // ... implement your functions like before
}

main.cpp – add namespace usage

//...
using namespace std;
using namespace dynamicArray;
//...

6

solved ‘ ‘ was not declared in this scope [closed]