0

i got the following error when compiling a word count program, **error: expected unqualified-id before '.' token.; this error is at line 5 //class Split_file.hpp.

  #ifndef SPLIT_FILE_HPP_H
#define SPLIT_FILE_HPP_H


class Split_file.hpp
{

        Split_file.hpp();
        virtual ~Split_file.hpp();

    protected:

    private:
};

#endif // SPLIT_FILE_HPP_H
5
Contributors
8
Replies
41
Views
1 Year
Discussion Span
Last Post by tinstaafl
0

Is it normal to name your classes to include a dot (.) ? I remember that syntax from structs in C, not C++, but I could be wrong.

1

Yep, it's the dot. Just call your class split_file or SplitFile or something. This thread made me browse the web for the naming conventions and do a little experimentation. Interestingly enough, I could stick a $ character in my class name and get away with it. But not a dot. Just stick with underscores, letters, and digits and you'll be fine.

0

it returns the same error.

It returns

**error: expected unqualified-id before '.' token

after you took the '.' out?

0

yes even after i took '.' out the same error still occur.

0

Post the updated file and exact error message with line number. No dot should be in the file, so no dot token can cause an error.

0

You can seek the stream to the desired position and then read stream. Check this piece of code.

// get size of file
infile.seekg(0,ifstream::end);
size=infile.tellg();
infile.seekg(0);

Learn C++ here https://hackr.io/tutorials/learn-c-c-plus-plus
All you need to do is to remember the position where you stopped reading infile, close outfile, open new outfile, reallocate buffers and read infile to buffer and write to second outfile.

1

Also remember that when you change the declaration of the class, you also have to change every where that name is used, like in the constructor and destructor(the prototype and the actual methods).

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.