Copy constructor- object not declared???

Hello!
Please, why is "another" not declared?

I wanted to copy first object using copy constructor!
Please ignore formula, it is not important!
Many thanks!!!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
using namespace std;

class BMI{
  public:
   string mynameis;
   string mysurnameis;
  private:
   int myheightis;
   int myweightis;
 public:

  BMI(string, string, int, int);
  BMI (const BMI& another); //COPY CONSTRUCTOR
  int bodymassindex(){ return myheightis*myweightis;}
  
};

BMI::BMI(string a, string b, int c, int d){
mynameis=a;
mysurnameis=b;
myheightis=c;
myweightis=d;
}

BMI::BMI(const BMI& another) : mynameis(another.mynameis), mysurnameis(another.mysurnameis), myheightis(another.myheightis), myweightis(another.myweightis) {}




int main(){
BMI an ("a", "ac", 10,20);
BMI marry("m", "mc", 40, 50);
BMI nelly("n", "nc", 80, 90);

cout<<an.mynameis<<": bmi is: "<<an.bodymassindex()<<endl;

cout<<another.mynameis<<": bmi is: "<<another.bodymassindex()<<endl;
return 0;
}
Last edited on
Please do not post more than once - http://www.cplusplus.com/forum/beginner/162408/
Last edited on
Sry, did not meen to post twice, got some error on my own pc s oI posted twice..THAKNS FOR ANSWER!!!
Topic archived. No new replies allowed.