Here's my code.
Code:
#ifndef TEXTFILE_H
# define TEXTFILE_H
#include <string>
class TextBuffer {
protected:
std::string lastFile;
std::string buffer;
int charCnt;
int wordCnt;
public:
TextBuffer();
TextBuffer(std::string);
std::string getLastFile() const { return lastFile; }
std::string getBuffer() const { return buffer; }
int getCharCnt() const { return charCnt; }
int getWordCnt() const { return wordCnt; }
void setBuffer(std::string toSet, bool willAppend);
bool OpenFile(std::string in_filename, bool willAppend);
void SaveFile(std::string in_filename);
};
#endif
Code:
#include "TextBuffer.h"
#include <fstream>
TextBuffer::TextBuffer():
buffer(""),
lastFile(""),
charCnt(0),
wordCnt(0) {
}
TextBuffer::TextBuffer(std::string in_lastFile):
buffer(""),
lastFile(in_lastFile),
charCnt(0),
wordCnt(0) {
}
... other functions not added...
and heres my test.cpp client program...
Code:
#include "TextBuffer.h"
#include <iostream>
using namespace std;
int main() {
TextBuffer myTextBuffer();
rotatedOne.OpenFile("../../two.txt", false);
cout << rotatedOne.getBuffer();
cout << "\n\nchars" << rotatedOne.getCharCnt() << endl << endl;
system("pause");
}
My entire project is much bigger than this, but I'm having trouble with using member initialization lists. This program doesnt compile and I get...
Code:
../test.cpp: In function `int main()':
../test.cpp:9: request for member `OpenFile' in `myTextBuffer()', which is of
non-aggregate type `TextBuffer ()()'
../test.cpp:10: request for member `getBuffer' in `myTextBuffer()', which is of
non-aggregate type `TextBuffer ()()'
../test.cpp:11: request for member `getCharCnt' in `myTextBuffer()', which is
of non-aggregate type `TextBuffer ()()'
yet if I base a string value to myTextBuffer. ie myTextBuffer("Untitled-1"); The program works fine and compiles fine. What am I doing wrong?
Please help thank you.