user1820339
user1820339

Reputation: 25

build errors in c++ code

I have following c++ code and i am getting build errors in it.I am unable to find out the errors please any one help.Here is the code

#include<stdlib.h>
#include <iostream.h>
using namespace std;

class PropertyPortal;
class PropertyType;
class Commercial;
class Residential;
void main()
class PropertyPortal  
{
private:

        int NoOfUsers;
        int UAN;
        char* Name;

        public:
       void setNoOfUsers(int no); 
       void setUAN(int u);      
       void setName(int n); 
       int getNoOfUsers(); 
       int getUAN(); 
       char getName();
       int getPropertyInfo(); 
       //constructors of the class
       PropertyPortal(); 
       PropertyPortal(int, int, char);
       //destructor of the class
       ~PropertyPortal ();

       void setNoOfUsers(int no)
       {
                        NoOfUsers>=1;
                        }
                        void setUAN (int u);
                        {
                        NoOfUsers>=0;
                        UAN>=1;
                        Name=Null;
                        }
                        PropertyPortal (int no, int u, char* n)
                        {
                        NoOfUsers>=no;
                        UAN=u
                        Name=VU-Real-Estate;
                        }
                        PropertyPortal (int no, int u, char* n)
                        {
                        NoOfUsers>=no; 
                        UAN=u
                        Name=n;
                        }
                        void setNoOfUsers(int no)
                        void setUAN(int u)
                        void setName(char n)
                        int getNoOfUsers()
                        int getUAN()
                        char getName()    
                        int getPropertyInfo();
class PropertyType  
{
      private:
              char* City
public:
        void setCity(char c); 
        char getCity(char c); 
        void getPropertyType();
        PropertyType();
        PropertyType(char);
        ~PropertyType();
        PropertyType();
{
        City=Null
}
        PropertyType(char* cCity)
{
        City=cCity
        }
        };          
class Commercial:PropertyType     
{
private:
        int PropertyValue
public:
       void setPropertyValue();
       int getPropertyValue();
       void getPlots();
       Commercial();
       Commercial(char);
       ~Commercial();
};

class Residential:PropertyType     
private:
        int PropertyValue;
public:
       void setPropertyValue();
       int getPropertyValue();
       int getPropertyCategory();     
};
void main ()
{
cout<<"This is just a prototype of all classes";
cout<<endl;
system("PAUSE");
}

I got error on line 2,32:2,10,103 Please help me to find out whats wrong and whats going on with the code.

Update enter image description here

Upvotes: 0

Views: 105

Answers (1)

BoBTFish
BoBTFish

Reputation: 19757

A lot of the errors are coming from having both function declarations and definitions inside the class. Do either

class Foo
{
    public:
        int func();
};
int Foo::func() { return 5; }

or

class Foo
{
    public:
        int func() { return 5; }
};

but not

class Foo
{
    public:
        int func();
        // ...
        int func() { return 5; }
};

I also see that you intend to have two constructors, one with default values, and one taking values from the creator. But then you do this:

PropertyPortal (int no, int u, char* n)
{
    NoOfUsers>=no;
    UAN=u
    Name=VU-Real-Estate;
}
PropertyPortal (int no, int u, char* n)
{
    NoOfUsers>=no; 
    UAN=u
    Name=n;
}

I suspect you really mean

PropertyPortal ()
{
    NoOfUsers=1;
    UAN=1;
    Name="VU-Real-Estate";
}
PropertyPortal (int no, int u, char* n)
{
    NoOfUsers=no; 
    UAN=u
    Name=strdup(n); // Remember to free() this later.
}

In fact, you'ld be even better off to scrap char*s all together, and use std::string, and maybe read about initializer lists.

Upvotes: 2

Related Questions