M
Materialised
I am having some issues with the following code, basically what I am
trying to do, is familierise myself with compiler warnings, when I try
to access a private or protected class function.
Here is the errors the compiler generates:
ex1.cpp: In function `int main()':
ex1.cpp:12: error: `testing' is not a class or namespace
ex1.cpp:12: error: `pubtest' undeclared (first use this function)
ex1.cpp:12: error: (Each undeclared identifier is reported only once for
each function it appears in.)
ex1.cpp:13: error: `testing' is not a class or namespace
ex1.cpp:13: error: `pritest' undeclared (first use this function)
ex1.cpp:14: error: `testing' is not a class or namespace
ex1.cpp:14: error: `protest' undeclared (first use this function)
test.cpp:1:24: ex1-Header.h: No such file or directory
test.cpp:4: error: `Test' has not been declared
test.cpp:9: error: `Test' has not been declared
test.cpp:14: error: `Test' has not been declared
Here is the code:
###ex1-Header.h
class Test {
public:
void pubtest();
private:
void pritest();
protected:
void protest();
};
###test.cpp
#include <ex1-Header.h>
#include <iostream>
void Test:ubtest() {
std::cout << "Public Test" << std::endl;
}
void Test:ritest() {
std::cout << "Private Test" << std::endl;
}
void Test:rotest() {
std::cout << "Protected Test" << std::endl;
}
###ex1.cpp
#include "ex1-Header.h"
#include <iostream>
using namespace std;
int main() {
Test testing;
testing:ubtest();
testing:ritest();
testing:rotest();
return 0;
}
I did expect compiler errors when trying to access the private and
protected functions, however even when I comment out the calls to these
functions the compiler still issues warnings.
Can anyone point me in the correct direction of where I am going wrong.
Thanks
--
Materialised
perl -e 'printf %silto%c%sal%c%s%ccodegurus%corg%c, ma, 58, mw, 107,
'er', 64, 46, 10;'
Bart: "What if you're a really good person, but you get into a really,
really bad fight and your leg gets gangrene and it has to be amputated.
Will it be waiting for you in heaven?"
trying to do, is familierise myself with compiler warnings, when I try
to access a private or protected class function.
Here is the errors the compiler generates:
ex1.cpp: In function `int main()':
ex1.cpp:12: error: `testing' is not a class or namespace
ex1.cpp:12: error: `pubtest' undeclared (first use this function)
ex1.cpp:12: error: (Each undeclared identifier is reported only once for
each function it appears in.)
ex1.cpp:13: error: `testing' is not a class or namespace
ex1.cpp:13: error: `pritest' undeclared (first use this function)
ex1.cpp:14: error: `testing' is not a class or namespace
ex1.cpp:14: error: `protest' undeclared (first use this function)
test.cpp:1:24: ex1-Header.h: No such file or directory
test.cpp:4: error: `Test' has not been declared
test.cpp:9: error: `Test' has not been declared
test.cpp:14: error: `Test' has not been declared
Here is the code:
###ex1-Header.h
class Test {
public:
void pubtest();
private:
void pritest();
protected:
void protest();
};
###test.cpp
#include <ex1-Header.h>
#include <iostream>
void Test:ubtest() {
std::cout << "Public Test" << std::endl;
}
void Test:ritest() {
std::cout << "Private Test" << std::endl;
}
void Test:rotest() {
std::cout << "Protected Test" << std::endl;
}
###ex1.cpp
#include "ex1-Header.h"
#include <iostream>
using namespace std;
int main() {
Test testing;
testing:ubtest();
testing:ritest();
testing:rotest();
return 0;
}
I did expect compiler errors when trying to access the private and
protected functions, however even when I comment out the calls to these
functions the compiler still issues warnings.
Can anyone point me in the correct direction of where I am going wrong.
Thanks
--
Materialised
perl -e 'printf %silto%c%sal%c%s%ccodegurus%corg%c, ma, 58, mw, 107,
'er', 64, 46, 10;'
Bart: "What if you're a really good person, but you get into a really,
really bad fight and your leg gets gangrene and it has to be amputated.
Will it be waiting for you in heaven?"