Compiler Errors

I'm getting a compiler error that says:
type qualifiers ignored on function return type.

getting that error twice.

any suggestions?

thank you1

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>

class SimpleCat
{
public:
	SimpleCat();
	SimpleCat(SimpleCat&);
	~SimpleCat();

	int GetAge() const { return itsAge; }
	void SetAge(int age) { itsAge = age; }

private:
	int itsAge;
};

SimpleCat::SimpleCat()
{
	std::cout << "Simple Cat constructor ... \n";
	itsAge = 1;
}

SimpleCat::SimpleCat(SimpleCat&)
{
	std::cout << "Simple Cat Copy constructor.... \n";
}

SimpleCat::~SimpleCat()
{
	std::cout << "Simple Cat Destructor ... \n";
}

const SimpleCat *const
FunctionTwo (const SimpleCat *const theCat);

int main()
{
	std::cout << "Making a cat ... \n";
	SimpleCat Frisky;
	std::cout << "Frisky is.. :";
	std::cout << Frisky.GetAge() << " years old \n";
	int age = 5;
	Frisky.SetAge(age);
	std::cout << "Frisky is ";
	std::cout << Frisky.GetAge() << " years old\n";
	std::cout << "Calling FunctionTwo .... \n";
	FunctionTwo(&Frisky);
	std::cout << "Frisky is ";
	std::cout << Frisky.GetAge() << " years old\n";
	return 0;
}

const SimpleCat * const FunctionTwo (const SimpleCat * const theCat)
{
	std::cout << "function two. returning... \n";
	std::cout << "Frisky is now " << theCat->GetAge();
	std::cout << " years old\n";
	return theCat;
}
Where are these errors appearing? Just copy/paste the whole error message.
constpasser.cpp:34:43: error: type qualifiers ignored on function return type [-Werror=ignored-qualifiers]
constpasser.cpp:53:68: error: type qualifiers ignored on function return type [-Werror=ignored-qualifiers]
cc1plus: all warnings being treated as errors
there are no const non-class rvalues in C++, so a function returning a const pointer is nonsense*, which is what the compiler is telling you.

Make it
const SimpleCat * FunctionTwo ( ...

*not to be confused with a pointer to const, which may be quite sensible
Last edited on
Topic archived. No new replies allowed.