#include <iostream>
using namespace std;



class Person
{
      private:
         string name;
      public:
         Person();
         Person(string the_name);
         string get_name() const;
        
};
////////////////////////////////////////////////////////////////
class vehicle
{
      protected:
         string name;
         int cylinders;
         Person owner;
      public:
         vehicle();
         vehicle(string _name, int _cylinders, Person _owner);
         void display()
         {
              cout << name;
              cout << cylinders;
              cout << owner.get_name();
         }
};

/////////////////////////////////////////////////////////////
class truck: private vehicle
{
      protected:
         double tons;
         int towCap;
      public:
         truck();
         truck(string _name, double _tons, int _towCap, int _cylinders, Person _owner);
         void display();
         bool setTons(double _tons);
         bool setTC(int _towCap);
         bool setC(int _cylinders);
         bool setName(string _name);
         bool setPerson(Person _owner);
};
////////////////////////////////////////
truck::truck()
{
   _name = "Toyota";
   _tons = 0;
   _towCap = 0;
   _cylinders = 0;
   _owner = "Nick";
}
///////////////////////////////////////
//truck::truck(string _name, double _tons, int _towCap, int _cylinders, Person _owner)

///////////////////////////////////////
void truck::display()
{
     /*cout << setTons(_tons);
     cout << setTC(_towCap);
     cout << setName(_name);
     cout << setPerson(_owner);*/
}
//////////////////////////////////////
bool truck::setTons(double _tons)
{
     if(_tons < 10)
     {
        _tons = 0;
        return false;
     }
     else
     {
         tons = _tons;
         return true;
     }  
}
////////////////////////////////////////
bool truck::setTC(int _towCap)
{
     if(_towCap < 100000)
     {
        _towCap = 0;
        return false;
     }
     else
     {
         towCap = _towCap;
         return true;
     }
}
/////////////////////////////////////////
bool setC(int _cylinders)
{
     if(_cylinders < 0)
     {
        _cylinders = 0;
        return false;
     }
     else
     {
         cylinders = _cylinders;
         return true;
     }
////////////////////////////////////////
bool truck::setName(string _name)
{
      
         name = _name;
         return true;
}
/////////////////////////////////////////
bool truck::setPerson(Person _owner)
{
        owner = _owner;
        return true;
}
}

here is my code...i have some errors and cant seem to fix them...can someone help me

<snip>
here is my code...i have some errors and cant seem to fix them...can someone help me

That doesn't give us much to go on. You want specific, targeted help, give us specific, targeted information....

I'm guessing your errors are related to the way you set up truck's inheritance of vehicle. You set it up as private inheritance, which is generally not a good idea. Change it to public and see what happens. If that doesn't fix it, post back with specifics.

[edit]
I think I see a couple other errors as well, but I want to see what you come back with.

no it doesnt work when i change it...my errors i get are in my truck constructor and my in my bool setC where it says cylinders is undefined

The problem in your constructor is you didn't reference the proper variable name(s). Get rid of the underscores ('_') in your variable names. The name "_cylinders" is not the same as "cylinders".

Your setC() method doesn't work because it is not properly associated with the truck class. You forgot the scope resolution part of the function's header.

#include <iostream>
#include <string>
using namespace std;



class Person
{
      private:
         string name;
      public:
         Person();
         Person(string the_name);
         string get_name() const;
        
};
////////////////////////////////////////////////////////////////
class vehicle: public Person
{
      protected:
         string name;
         string vehicleName;
         int cylinders;
         Person owner;
      public:
         vehicle();
         vehicle(string _vehicleName, int _cylinders, Person _owner);
         void set_Cylinders(int new_cylinders);
         void set_vehicleName(string new_vehicleName);
         int get_cylinders() const;
         string get_vehicleName() const;
};

/////////////////////////////////////////////////////////////
class truck: public vehicle
{
      protected:
         string truckName;
         double tons;
         int towCap;
      public:
         truck();
         truck(string _truckName, double _tons, int _towCap, int _cylinders, Person _owner);
         bool setTons(double _tons);
         bool setTC(int _towCap);
         bool setC(int _cylinders);
         bool setName(string _truckName);
         bool setPerson(Person _owner);
};
////////////////////////////////////////
Person::Person(): name("No name yet")
{
  
}
///////////////////////////////////////
Person::Person(string the_name): name(the_name)
{
                    
}
////////////////////////////////////////
string Person::get_name() const
{
   return name;
}
////////////////////////////////////////
vehicle::vehicle(): Person(), cylinders(0), name("No name yet")
{
                    
}
///////////////////////////////////////
vehicle::vehicle(string _vehicleName, int _cylinders, Person _owner): Person(_owner), cylinders(_cylinders), vehicleName(_vehicleName)
{
                        
}
////////////////////////////////////////
void vehicle::set_Cylinders(int new_cylinders)
{
     cylinders = new_cylinders;
}
////////////////////////////////////////
int vehicle::get_cylinders() const
{
    return cylinders;
}
/////////////////////////////////////////
void vehicle::set_vehicleName(string new_vehicleName)
{
   vehicleName = new_vehicleName;
}
////////////////////////////////////////
string vehicle::get_vehicleName() const
{
   return vehicleName;
}
////////////////////////////////////////
truck::truck(): Person(), vehicle(), tons(0), towCap(0), truckName("No name yet")
{

}
////////////////////////////////////////
truck::truck(string _truckName, double _tons, int _towCap, int _cylinders, Person _owner): Person(_owner), cylinders(_cylinders), truckName(_truckName), tons(_tons), towCap(_towCap)
{

}
///////////////////////////////////////
bool truck::setTons(double _tons)
{
     if(_tons < 10)
     {
        _tons = 0;
        return false;
     }
     else
     {
         tons = _tons;
         return true;
     }  
}
////////////////////////////////////////
bool truck::setTC(int _towCap)
{
     if(_towCap < 100000)
     {
        _towCap = 0;
        return false;
     }
     else
     {
         towCap = _towCap;
         return true;
     }
}
/////////////////////////////////////////
bool truck::setC(int _cylinders)
{
     if(_cylinders < 0)
     {
        _cylinders = 0;
        return false;
     }
     else
     {
         cylinders = _cylinders;
         return true;
     }
////////////////////////////////////////
bool truck::setName(string _name)
{
      
         name = _name;
         return true;
}
/////////////////////////////////////////
bool truck::setPerson(Person _owner)
{
        owner = _owner;
        return true;
}
}

im still getting errors...can someone help

Not unless you tell us what the errors are...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.