Hey I know this is really simple, I'm studying my first course of C++. In my prac for the week it asks:

"A TrainCar is a base class representing carriages for a train. It defines no attributes but has a public function called shape which accepts no arguments and returns a string object. The shape a TrainCar shape function returns an empty string."

Within this base class object. I understand that there is one function called shape which accepts no arguments and returns a string object. What I dont understand is "has no attributes"? Does that mean that they're are no variables allowed in the program?

ie

class trainCar
{
   public: 
      void print();      // I understand this
   private:
      string shape;    // is this what my lecture means by not defining attibutes? according
                            //  to the requirments of the program can I use this prive variable or
                            // is this what a attribute is?
};

I think your lecturer meant following:

class TrainCar
{
public:
  virtual string shape(){ return ""; }
};
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.