how to fix [Error] expected unqualified-id at end of input

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atiqah
    New Member
    • May 2014
    • 1

    how to fix [Error] expected unqualified-id at end of input

    Code:
    #include <iostream>
    using namespace std;
    class DB;
    class DM{
    	public:
    		DM(){}
    		DM (float meter, float cm);
    		friend int func(DM,DB);
    };
    
    class DB
    {
    float ft;
    float inches;
    
    public:
    DB(){}
    DB(float fe,float inc){
    ft=fe;
    inches=inc;
    };
    
    void display(){
    
    	cout<<"\n Feet is :"<<ft;
    	cout<<"\nInches are:"<<inches;
    };
    int main (){
    	DM a;
    	DB b;
    	cout<<"Data : "<<func(a, b);
    	return 0;
    }
    Last edited by Rabbit; May 5 '14, 04:05 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • stdq
    New Member
    • Apr 2013
    • 94

    #2
    Hello! I have some questions/observations:

    1. Why did you write class DB in both lines 3 and 11?
    2. In line 25, you try to directly access private variable ft. It can't be done, even if you have an object of its class - DB (which you don't). The same happens in line 26 with variable inches.
    3. In which line(s) is the error, according to the compiler/linker?

    Comment

    • mikele
      New Member
      • May 2014
      • 6

      #3
      You need one more '};' after finishing main(), for class DB

      Comment

      Working...