Class

Hey Guys. I have a problem here. I cant compil this code. Every time I get the massage:

1>c:\users\vitali\desktop\studium\informatik\classtut\classtut\main.cpp(24): error C3867: 'BMI::getHeight': function call missing argument list; use '&BMI::getHeight' to create a pointer to member
1>c:\users\vitali\desktop\studium\informatik\classtut\classtut\main.cpp(25): error C3867: 'BMI::getWeight': function call missing argument list; use '&BMI::getWeight' to create a pointer to member

I've allraedy tryed to find something in Internet, but without reault. Please help.

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

//main.cpp

  #include <iostream>
#include <string>

#include "BMI.h"

using namespace std;

int main()
{
	//Variablen
	string name;
	int height;
	double weight;

	cout << "Enter your Name: ";
	cin >> name;
	cout << "\n\nEnter you height: ";
	cin >> height;
	cout << "Enter your weight: ";
	cin >> weight;

	BMI Student_1(name, height, weight);

	cout << endl << "Name: " << Student_1.getName() << endl << "Height: " << Student_1.getHeight << endl
		<< "Weight: " << Student_1.getWeight << endl;


	return 0;
}


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
41
42
//BMI.h

  #pragma once
#include <iostream>
#include <string>

using namespace std;

#ifndef BMI_H
#define BMI_H

//Headerfile --> Function declaration
class BMI
{
private:
	//Member variables
	string newName;
	int newHeight;
	double newWeight;

public:
	//Default Constructor
	BMI();

	//Accessor Function(Geben die MemberVariablen wieder)
	string getName() const;
	// getName - return name of Student
	
	int getHeight() const;
	// getHeight() gibt die Größe wieder

	double getWeight() const;
	// getWeight gibt das Gewicht wieder

	//Overload Constractor
	BMI(string, int, double);

	//Destructor
	~BMI();
};

#endif 


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
//BMI.cpp

  //Function declaration

#include "BMI.h"


BMI::BMI()
{
	newHeight = 0;
	
}


BMI::BMI(string name, int height, double weight)
{
	newName = name;
	newHeight = height;
	newWeight = weight;
}

BMI::~BMI()
{}

string BMI::getName() const
{
	return newName;
}

int BMI::getHeight() const
{
	return newHeight;
}

double BMI::getWeight() const
{
	return newWeight;
}
Morning dude,

That's a really unhelpful error message from the compiler, but all it's saying is this:

Change this:
1
2
cout << endl << "Name: " << Student_1.getName() << endl << "Height: " << Student_1.getHeight << endl
		<< "Weight: " << Student_1.getWeight << endl;


to this:
1
2
	cout << endl << "Name: " << Student_1.getName() << endl << "Height: " << Student_1.getHeight() << endl
		<< "Weight: " << Student_1.getWeight() << endl;


In other words, you were only missing a few brackets to call your functions correctly.
Last edited on
Nice, thank you. Yes, the problem is now gone
Topic archived. No new replies allowed.