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::pubtest() {
std::cout << "Public Test" << std::endl;
}
void Test::pritest() {
std::cout << "Private Test" << std::endl;
}
void Test::protest() {
std::cout << "Protected Test" << std::endl;
}
###ex1.cpp
#include "ex1-Header.h"
#include <iostream>
using namespace std;
int main() {
Test testing;
testing::pubtes t();
testing::prites t();
testing::protes t();
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%co rg%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?" 3 2841
Le lundi 2 mai 2005 à 13:20:50, Materialised a écrit dans
comp.lang.c++*: 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
[snip]
Test testing; testing::pubtes t(); testing::prites t(); testing::protes t();
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
The compilder did: `testing' is not a class or namespace. '::' applies
to a class or a namespace, not an object.
testing.pubtest ();
testing.pritest ();
testing.protest ();
--
___________ 02/05/2005 13:25:10
_/ _ \_`_`_`_) Serge PACCALIN -- sp ad mailclub.net
\ \_L_) Il faut donc que les hommes commencent
-'(__) par n'être pas fanatiques pour mériter
_/___(_) la tolérance. -- Voltaire, 1763
Materialised wrote: 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::pubtest() { std::cout << "Public Test" << std::endl; } void Test::pritest() { std::cout << "Private Test" << std::endl; } void Test::protest() { std::cout << "Protected Test" << std::endl; }
###ex1.cpp #include "ex1-Header.h" #include <iostream>
using namespace std;
int main() { Test testing; testing::pubtes t(); testing::prites t(); testing::protes t();
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
My bad, I should have been using object.method() ;
Thanks Anyway.
--
Materialised
perl -e 'printf %silto%c%sal%c% s%ccodegurus%co rg%c, ma, 58, mw, 107,
'er', 64, 46, 10;'
Homer: "Ha ha! Look at this country! ? R U Gay!? Ha ha!" (looking at
Uruguay on the globe)
Hi
Nothing you have to access the object using the . operatore instead of
scope resolution operator
check it below
#include <iostream>
using namespace std;
class Test {
public:
void pubtest();
private:
void pritest();
protected:
void protest();
};
void Test::pubtest() {
std::cout << "Public Test" << std::endl;
}
void Test::pritest() {
std::cout << "Private Test" << std::endl;
}
void Test::protest() {
std::cout << "Protected Test" << std::endl;
}
int main() {
Test testing;
testing.pubtest ();
//testing::pubtes t();
// testing.pritest ();
// testing::protes t();
return 0;
}
MJ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: xixi |
last post by:
we are using db2 udb v8.1 on win 64 bit with fp3 with type 4 db2jcc.jar driver.
such error generated , please help me understand this , thanks
2004-01-12-14.09.02.400000 Instance:DB2 Node:000
PID:1788(db2syscs.exe) TID:980 Appid:none
DRDA Application Server sqljsCleanup Probe:60
DIA0001E An internal error occurred. Report the...
|
by: timVerizon |
last post by:
Hoping someone can help here..
Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions
ERROR SQL0904N Unsuccessful execution
caused by an unavailable resource. Reason code: '', type of resource:
'', and resource name: ''. SQLSTATE=57011 .
When looking in db2diag.log, we found the following that seemed to
correspond to each...
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much appreciated.
Thanks in advance
|
by: wmkew |
last post by:
Hello everyone
I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with LIBCMT(D).DLL. (My requirement is that we can't link with MSVCRT(D).LIB.) Below are steps I've followed, and the resulting problems
1. Using the...
|
by: Ming Zhu |
last post by:
Hi, all,
I'm new to .NET and ASP.NET. I only use .NET Framework 1.0. I'm
reading the book "C# developer's guide to ASP.NET". But I find there
is no place to download the code used inside this book.
Anyway, my problem is the following example doesn't work. It's a
simple page using HTML control Anchor. But I meet the following
error. ...
| |
by: Alixx Skevington |
last post by:
OK why does the following code work in a Windows form with a crystal report
viewer but not in a webform. I get the usual
CrystalReports.EngineLogONException logon Failed when this is called in aspx.
Any help will be very much apprecaited
Alixx
This is the code in the calling aspx Page
|
by: Shawn |
last post by:
JIT Debugging failed with the following error: Access is denied.
JIT Debugging was initiated by the following account 'PLISKEN\ASPNET'
I get this messag in a dialog window when I try to open an asp.net page. If
I press OK then I get a page with this message:
Server Application Unavailable
The web application you are attempting to access...
|
by: mike_li |
last post by:
On Window 2000 Professional Server
DB2 UDB
Level:
DB2 code release "SQL07029" with level identifie
"030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and
"WR21337".
In the db2diag.log,
----------------------------------------------------
2005-12-20-10.05.43.278000 Instance:MC Node:000
|
by: tshad |
last post by:
This has been driving me crazy.
I have been trying to get the error handling working on my system and can
get parts of it working and others won't work at all.
I found that you can't access session variables from Application_Error
event, but I need to so I don't need to set up traces to see what they are
during an error. I am emailing...
|
by: sara |
last post by:
I have a report that runs fine with data. If there is no data, I have
its NO Data event sending a MsgBox and cancelling the report.
Then it seems I still get the 2501 message on the Open Report command,
even though I have the code to trap Err 2501 (from many postings - all
looked the same to me) on the button the user pressed to get the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |