Click here to Skip to main content
15,922,419 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWait for your Help! Pin
YunYan2-Sep-04 1:07
YunYan2-Sep-04 1:07 
GeneralAny body can help me! Pin
YunYan2-Sep-04 2:49
YunYan2-Sep-04 2:49 
GeneralRe: Why LoadMenu() Failed! Errorcode=1814 Pin
David Crow2-Sep-04 3:00
David Crow2-Sep-04 3:00 
GeneralWM_QUERYENDSESSION From a dll Pin
AssemblySoft1-Sep-04 23:25
AssemblySoft1-Sep-04 23:25 
Generalpressed button sends message Pin
Tibor Blazko1-Sep-04 22:57
Tibor Blazko1-Sep-04 22:57 
GeneralHelp me!!!!! Pin
Anonymous1-Sep-04 22:44
Anonymous1-Sep-04 22:44 
GeneralSQL_ATTR_CONNECTION_DEAD attribute of MySQL not working as expected Pin
Anonymous1-Sep-04 22:37
Anonymous1-Sep-04 22:37 
GeneralPointer array access outside a class! Pin
CreepingFeature1-Sep-04 22:06
CreepingFeature1-Sep-04 22:06 
Hi everyone!

First, I appologise for my last post Blush | :O !

Anyway, got this here code in main():

int number1 = 5;<br />
int number2 = 10;<br />
<br />
int *p_number1 = &number1;<br />
int *p_number2 = &number2;<br />
<br />
int *arrayAddress;<br />
int *pointerArray[2];<br />
<br />
pointerArray[0] = p_number1;<br />
pointerArray[1] = p_number2;<br />
    <br />
cout << " Pointer array at [0]: " << pointerArray[0];<br />
cout << endl;<br />
cout << " Pointer array at [1]: " << pointerArray[1];<br />
<br />
cout << endl;<br />
cout << endl;<br />
<br />
cout << " Pointer array deref at [0]: " << *pointerArray[0];<br />
cout << endl;<br />
cout << " Pointer array deref at [1]: " << *pointerArray[1];<br />
<br />
cout << endl;<br />
cout << endl;<br />
<br />
arrayAddress = pointerArray[0];<br />
<br />
cout << endl;<br />
cout << " Array address: " << arrayAddress;<br />
cout << endl;<br />
cout << " Array access through address: " << arrayAddress[0];


It compiles and the last statment prints 5 the actual value at the address that is stored in pointerArray[0]. But if I was to put arrayAddress[1] I get garbage.

Question: I have a class that contains the above code, or an array that points to a bunch of variables. Is there a way to pass the name of the array
outside the class private: to main() and then access it as if i was inside the class.

I am asking because I have a class private: filled with 24 variables, and got 24 members in public: that can return the current value of those variables. To shrink the class I decided to make an array of pointers to those variables and pass it outside the class so that instead of using the member functions I would lookup/change values directly thru the array of pointers.

If you have another solution to this problem PLEASE HELP!

Thanks for your time! Smile | :)
GeneralRe: Pointer array access outside a class! Pin
Mike Beckerleg1-Sep-04 22:35
Mike Beckerleg1-Sep-04 22:35 
GeneralRe: Pointer array access outside a class! Pin
Anonymous2-Sep-04 2:20
Anonymous2-Sep-04 2:20 
GeneralRe: Pointer array access outside a class! Pin
Mike Beckerleg2-Sep-04 3:09
Mike Beckerleg2-Sep-04 3:09 
GeneralRe: Pointer array access outside a class! Pin
CreepingFeature2-Sep-04 21:00
CreepingFeature2-Sep-04 21:00 
GeneralZIP files programmatically using MFC C++ Pin
anderslundsgard1-Sep-04 20:37
anderslundsgard1-Sep-04 20:37 
GeneralRe: ZIP files programmatically using MFC C++ Pin
PJ Arends1-Sep-04 21:18
professionalPJ Arends1-Sep-04 21:18 
GeneralControlling Device and Internet Pin
zahid_ash1-Sep-04 19:46
zahid_ash1-Sep-04 19:46 
GeneralEdit Box messages Pin
shiraztk1-Sep-04 19:21
shiraztk1-Sep-04 19:21 
GeneralRe: Edit Box messages Pin
Scozturk1-Sep-04 21:45
professionalScozturk1-Sep-04 21:45 
GeneralRe: Edit Box messages Pin
shiraztk1-Sep-04 22:27
shiraztk1-Sep-04 22:27 
GeneralRe: Edit Box messages Pin
wb2-Sep-04 0:52
wb2-Sep-04 0:52 
GeneralRe: Edit Box messages Pin
James R. Twine2-Sep-04 3:48
James R. Twine2-Sep-04 3:48 
GeneralRe: Edit Box messages Pin
shiraztk2-Sep-04 20:16
shiraztk2-Sep-04 20:16 
GeneralMessge routing in SDI/MDI Pin
vikramlinux1-Sep-04 19:02
vikramlinux1-Sep-04 19:02 
Questionanybody has experience of using Nero SDK? Pin
lonely_life1-Sep-04 18:59
lonely_life1-Sep-04 18:59 
Generalscanlogd Pin
Anonymous1-Sep-04 18:58
Anonymous1-Sep-04 18:58 
GeneralOnLButtonDown() question Pin
persian_boi1-Sep-04 17:40
persian_boi1-Sep-04 17:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.