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
Member Avatar for RudyM

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.

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.

i tried all the so, it returns the same error.

it returns the same error.

It returns

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

after you took the '.' out?

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

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.

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.

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.