C++ error: "size" declared as function returning a function -
i'm not sure why getting error during compilation says "error: "size" declared function returning function" when size() returning type size_t. appreciated, thanks.
// text.h #include <cstring> #include <fstream> #include <iostream> using namespace std; namespace w3 { class text { string* arrayrecords; size_t numrecords; public: text(); text(const char* filename); size_t size() const; ~text(); }; } // text.cpp #include "text.h" namespace w3 { text::text() { numrecords = 0; arrayrecords = nullptr; } text::text(const char* filename) { // } size_t text::size() const() { return numrecords; } text::~text() { if(arrayrecords) delete [] arrayrecords; } }
the problem line:
size_t text::size() const() remove () after const, have:
size_t text::size() const
Comments
Post a Comment