Thread: Having an ofstream in the private data of a class

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    17

    Having an ofstream in the private data of a class

    Hey everyone,

    VC++ is givin me errors like
    Code:
     error C2146: syntax error : missing ';' before identifier '_fileStream1'
    error C2501: 'ofstream' : missing storage-class or type specifiers
    because of the line
    Code:
     ofstream _fileStream1;
    which is in the private data section of my FileWriter class. I've attached the code below but i think i have included what i need to, is there somethin more about ofstreams that i need to know?

    Code:
    #include <stdio.h>
    #include <fstream>
    #include <string>
    
    class FileWriter  
    {
    public:
    	FileWriter(char* file_path /*name of file to be written*/); 
    
    	void write(char* item_name, int item_number);
    
    private:
    
    	ofstream _fileStream1;
    };

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    148

    Re: Having an ofstream in the private data of a class

    Code:
    ...
    private:
    
    	std:: ofstream _fileStream1;
    };

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    17
    Cheers Wledge.

    Nice1.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  2. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  3. C diamonds and perls :°)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM
  4. Post programs
    By GaPe in forum C# Programming
    Replies: 8
    Last Post: 05-12-2002, 11:07 AM