is this good practise or even possible as i'm not on my comp.

class C3dshape
{
private:
int mLength;
int mWidth;
int mDepth;
public:
int getlength();
int getwidth();
int getdepth();
void setvalues();
};
int C3dshape::getlength()
return mLength;
int C3dshape::getwidth()
return mWidth;
int C3dshape::getdepth()
return mDepth;
void C3dshape::setvalues()
{
length = mLength;
width = mWidth;
depth = mDepth;
}

Is it possible to do what? There is no restriction on the number of getters you can put in a class.And you have to put { and } around all functions even if they are only one line. I always make one liners inline code instead of in an implemnentation file

class C3dshape
{
private:
   int mLength;
   int mWidth;
   int mDepth;
public:
   int getlength() {return mLength;}
   int getwidth() {return mWidth;}
   int getdepth() {return mDepth;}
   void setvalues(int Length,int Width, int Depth)
   {
      mLength = Length;
      mDepth = Depth;
      mWidth = Width;
   }
};

the question was the title so can there be multiple getters to one setter?

Is it possible to do what? There is no restriction on the number of getters you can put in a class.And you have to put { and } around all functions even if they are only one line. I always make one liners inline code instead of in an implemnentation file

class C3dshape
{
private:
   int mLength;
   int mWidth;
   int mDepth;
public:
   int getlength() {return mLength;}
   int getwidth() {return mWidth;}
   int getdepth() {return mDepth;}
   void setvalues(int Length,int Width, int Depth)
   {
      mLength = Length;
      mDepth = Depth;
      mWidth = Width;
   }
};

Didn't the example I posted help you? It contains one setter and three getters. If that isn't what you are asking then you need to explain yourself better and with example. The example you originally posted is almost identical to what I posted.

the question was the title so can there be multiple getters to one setter?

Theres absolutely nothing wrong with setting all three in one function and then having independent get functions for each one. Cheers !

Didn't the example I posted help you? It contains one setter and three getters. If that isn't what you are asking then you need to explain yourself better and with example. The example you originally posted is almost identical to what I posted.

sorry i paid more attention to the text than the code so i didn't really see your answer thanks though

Well, did we answer your question or not? If we did then please mark this thread Solved.

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.