Compiling error (Maybe a syntax error)

This is a discussion on Compiling error (Maybe a syntax error) within the C++ Programming forums, part of the General Programming Boards category; Hi everybody, i got an error during compiling(Line 34)...the compilier says: "error C2146: syntax error : missing ';' before identifier ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    56

    Compiling error (Maybe a syntax error)

    Hi everybody,

    i got an error during compiling(Line 34)...the compilier says:
    "error C2146: syntax error : missing ';' before identifier 'VolumeOfPool'"

    here is my program:

    Code:
    #include <iostream.h>
    class SwimmingPool
    {
    private:
    	int length;
    	int width;
    	int depth;
    	float volume;
    	float capacity;
    	float time;
    	float VolumeOfPool();
    	float CapacityOfPool();
    	float TimeToFill();
    	
    public:
    	SwimmingPool();
    	SwimmingPool(int,int,int);
    	void displayStat();
    	~SwimmingPool();
    };
    
    SwimmingPool::SwimmingPool()
    {
    	length=0;width=0;depth=0;
    }
    
    SwimmingPool::SwimmingPool(int l, int w, int d)
    {
    	length=l;
    	width=w;
    	depth=d;
    }
    
    float::SwimmingPool VolumeOfPool()                     //LINE 34
    {
    	volume=length*width*depth;
    	return (volume);
    }
    
    float::SwimmingPool CapacityOfPool()
    {
    	const float PERGALLON = 7.48;
    	capacity=PERGALLON*volume;
    	return (capacity);
    }
    
    float::SwimmingPool TimeToFill ()
    {
    	time = capacity/50;
    	return (time);
    }
    
    void::SwimmingPool DisplayStat ()
    {
    	cout<<"lengh is :"<<length;
    	cout<<"width is :"<<width;
    	cout<<"depth is :"<<depth;
    	cout<<"volume is : "<<VolumeOfPool();
    	cout<<"Capacity is: "<<CapacityOfPool();
    	cout<<"Time is: "<<TimeToFill();
    	
    }
    	
    int main()
    {
    	
    	SwimmingPool d1(10,6,4);
    	d1.DisplayStat();
    	
    	SwimmingPool d2(30,15,6);
    	d2.DisplayStat();
    
    	return 0;
    }
    Thanks for helping

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    try this with all your fxn definitions:

    Code:
    float SwimmingPool::VolumeOfPool()
    {
        //code
    }

  3. #3
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I glanced this over and knew something looked off, never clicked that the scope operators were in the wrong spot, nice catch.

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    56

    Another error (Linking error)

    THanks a lot,
    now, i have no error during compiling but only 2 warning.

    However, i got 2 error while linking because of my destructor, so i can't run my program, here is my program. (However, if i remove the line 19, my program work fine)

    Code:
    #include <iostream.h>
    class SwimmingPool
    {
    private:
    	int length;
    	int width;
    	int depth;
    	float volume;
    	float capacity;
    	float time;
    	float VolumeOfPool();
    	float CapacityOfPool();
    	float TimeToFill();
    	
    public:
    	SwimmingPool();
    	SwimmingPool(int,int,int);
    	void DisplayStat();
    	~SwimmingPool();                                    //Line 19
    };
    
    SwimmingPool::SwimmingPool()
    {
    	length=0;width=0;depth=0;
    }
    
    SwimmingPool::SwimmingPool(int l, int w, int d)
    {
    	length=l;
    	width=w;
    	depth=d;
    }
    
    float SwimmingPool::VolumeOfPool()
    {
    	volume=length*width*depth;
    	return (volume);
    }
    
    float SwimmingPool::CapacityOfPool()
    {
    	const float PERGALLON = 7.48;
    	capacity=PERGALLON*volume;
    	return (capacity);
    }
    
    float SwimmingPool::TimeToFill ()
    {
    	time = capacity/50;
    	return (time);
    }
    
    void SwimmingPool::DisplayStat ()
    {
    	cout<<"lengh is :"<<length<<endl;
    	cout<<"width is :"<<width<<endl;
    	cout<<"depth is :"<<depth<<endl;
    	cout<<"volume is : "<<VolumeOfPool()<<endl;
    	cout<<"Capacity is: "<<CapacityOfPool()<<endl;
    	cout<<"Time is: "<<TimeToFill()<<endl<<endl;
    }
    	
    int main()
    {
    	
    	SwimmingPool d1(10,6,4);
    	d1.DisplayStat();
    	
    	SwimmingPool d2(30,15,6);
    	d2.DisplayStat();
    
    	return 0;
    }

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    you have not defined a destructor. at that, you shouldn't need it. it won't do anything, so the default destructor done by the compiler will suffice. you shouldn't need a destructor unless you need to delete allocated memory.

  6. #6
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    whats a reconstructor?

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Originally posted by RoD
    whats a reconstructor?
    never heard of it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  5. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM

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