| | |
*this problem (help?)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
C++ Syntax (Toggle Plain Text)
void myClass<temp_Type>::myFunction(myClass<temp_Type>* &firstClass, myClass<temp_Type>* secondClass) { } [call] myFunction(*this, &secondClass);
I think I am fundamentally challenged on the "this" qualifier. I want to pass a pointer to the current object(ie the object I am calling the function from), but am stuck trying to pass the "this". Are there any other methods to go about something such as this?
Last edited by chococrack; Oct 4th, 2008 at 2:29 pm.
I would love to change the world, but they won't give me the source code
this is a pointer, *this dereferences the pointer. So if you want to pass a pointer just don't use the asterisk.
That looks like a recursive function call, I doubt you even need to pass this pointer because the compiler will do that anyway.
myFunction(this, ©Class); That doesn't mean it will solve your problem, but that's how to pass pointers.That looks like a recursive function call, I doubt you even need to pass this pointer because the compiler will do that anyway.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
From http://www.codersource.net/cpp_tutor...s_pointer.html
this pointers are not modifiable.
So I wouldn't recommend that
this pointers are not modifiable.
So I wouldn't recommend that
The special pointer
It seems the myfunction member has a slightly unusual signature with the 1st parameter of type "a reference to a pointer to myClass<temp_Type>". Can you explain what do you want to do with the 1st parameter of this member function?
this has type Class*const (not Class*) so you can't pass this as an argument to myFunction.It seems the myfunction member has a slightly unusual signature with the 1st parameter of type "a reference to a pointer to myClass<temp_Type>". Can you explain what do you want to do with the 1st parameter of this member function?
Last edited by ArkM; Oct 4th, 2008 at 2:59 pm.
>I ended up having to re-route what I was trying to accomplish.
What were you trying to accomplish? The way I'm reading your problem, you're confused about what
What were you trying to accomplish? The way I'm reading your problem, you're confused about what
this is. A pointer to the current object is always available from a non-static member function; you don't have to pass it explicitly. I'm here to prove you wrong.
![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Installing Windows 98 On VMware. Floppy problem (Windows 95 / 98 / Me)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Cellphones, PDAs and Handheld Devices)
- Connection Problems (Networking Hardware Configuration)
- Encoding (Unicode) problem in IE 6.0 (Web Browsers)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the C++ Forum
- Previous Thread: Comparision Between Tarbo C++, Visual C++
- Next Thread: Set position in Stream
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets







Time for a new approach ::cracks fingers::