Class issue

This is a discussion on Class issue within the C++ Programming forums, part of the General Programming Boards category; This gives me an error about not recognizing railcar. What am I doing wrong? Code: // #include <iostream> #include <string> ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    28

    Class issue

    This gives me an error about not recognizing railcar. What am I doing wrong?
    Code:
    //
    #include <iostream>
    #include <string>
    #include <fstream>
    #include <cmath>
    #include <stack>
    #include <ctime>
    #include <deque>
    
    using namespace std;
    
    //WORKAROUND
    	class railcar;
    	ostream & operator<<(ostream &, railcar & );
    //WORKAROUND
    
    
    
    class railcar;
    
    {private:
    	string cartype;
    	int id;
    	int train;
    
    public:
    	
    	railcar(string c, int i, int t):cartype(c),id(i),train(t) { }
    	
    	railcar(): cartype(""),id(0),train(0) { };
    	
    	int idtrain() { return id; }
    	
    	friend ostream & operator << (ostream &, railcar & r);
    	
    	typedef long_train deque <railcar *>;
    
    	railcar :: railcar (string c, int i, int t)
    	{ 
    	  railcar=r;	
    	  cartype=c;
    	  id=i;
    	  train=t;
    	}
    };
    
    ostream & operator<<(ostream & ostr, railcar & r)
    
    {
    	ostr << r.cartype << "   " << r.id << "    " << r.train;
    	return ostr;
    }
    
    
    
    int  ()
    {
    	ofstream car_file("railcars.txt");
    	std::cout << car_file << endl;
    
    
    
    
    
    
    
    
    
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Nov 2003
    Posts
    3

    Re: Class issue

    Originally posted by PunkyBunny300
    Code:
    class railcar;
    
    {private:
    	string cartype;
    	int id;
    	int train;
    
    public:
    	
    	railcar(string c, int i, int t):cartype(c),id(i),train(t) { }
    	
    	railcar(): cartype(""),id(0),train(0) { };
    	
    	int idtrain() { return id; }
    	
    	friend ostream & operator << (ostream &, railcar & r);
    	
    	typedef long_train deque <railcar *>;
    
    	railcar :: railcar (string c, int i, int t)
    	{ 
    	  railcar=r;	
    	  cartype=c;
    	  id=i;
    	  train=t;
    	}
    };
    at the start it should be
    Code:
    class railcar
    {
    ...
    };
    Hope that helps

  3. #3
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Whoa! What happened to main?

  4. #4
    Registered User
    Join Date
    Dec 2002
    Posts
    28
    thats all the declarations before main.

  5. #5
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    No, I mean:
    Code:
    int  ()
    {
    	ofstream car_file("railcars.txt");
    	std::cout << car_file << endl;
    
    
    
    
    
    
    
    
    
    return 0;
    }
    What happened to main as in "where'd it go"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Inherite nonvirtual class functionality
    By DrSnuggles in forum C++ Programming
    Replies: 2
    Last Post: 04-30-2009, 02:52 PM
  3. Need help to build network class
    By weeb0 in forum C++ Programming
    Replies: 0
    Last Post: 02-01-2006, 11:33 AM
  4. class errors
    By romeoz in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2003, 08:57 PM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 02:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21