| | |
How to access a Public Pointer value of a class directly?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2004
Posts: 13
Reputation:
Solved Threads: 0
Hi
I made a class that has a public integer pointer
and I use this pointer in main like code below: (Just a sample code,I know about memory leaks and other related bugs,just a sample)
#include<iostream.h>
class Cat
{
public:
int *Pointer;
};
main()
{
Cat *pCat;
pCat=new Cat;
pCat->Pointer = new int;
pCat->*Pointer=34 //this makes a compiler error
delete pCat->Pointer;
return 0;
}
I need to access this(Pointer) public pointer of class cat directly not from class methods;
I made a class that has a public integer pointer
and I use this pointer in main like code below: (Just a sample code,I know about memory leaks and other related bugs,just a sample)
#include<iostream.h>
class Cat
{
public:
int *Pointer;
};
main()
{
Cat *pCat;
pCat=new Cat;
pCat->Pointer = new int;
pCat->*Pointer=34 //this makes a compiler error
delete pCat->Pointer;
return 0;
}
I need to access this(Pointer) public pointer of class cat directly not from class methods;
![]() |
Similar Threads
- Why the member functions of one class can access to private data member of other obj? (C++)
- Pointer To Class (C++)
- How to.. "access-back" class members? (Java)
- How to Access a Public Filed from a class and that Field value From the other Class (Java)
- How to access a variable of a diff class (C++)
Other Threads in the C++ Forum
- Previous Thread: functions
- Next Thread: Why can't I use Pointers to point to a Enumurated Constant
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





