|
It means the function is in the global anonymous namespace, i.e. not part of any namespace nor class.
|
|
|
|
|
Can it reference any of the members out of the method is running from
e.g.
Class A
{
public:
void mymethod();
private:
int private_data;
}
a::mymethod()
{
::mycall(private_data); // is this okay
|
|
|
|
|
ForNow wrote: Class A
{
public:
void mymethod();
private:
int private_data;
}
a::mymethod()
{
::mycall(private_data); // is this okay
Sorry, but that piece of code makes absolutely no sense.
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|
|
Is it because I have a small "a".
A::mymethod()
|
|
|
|
|
The line a:mymethod() would be ok IF you'd actually created an instance of class A named a which you've not shown so in the context we have it's not ok.
Using a call like A::mymethod() can only be done if mymethod is declared as a static member function, you need an instance of the class to call regular member functions.
Your ::mycall(private_data) won't work if you're expecting private_data from class A because, again, you'd need to have an instance of class A for the member private_data to exist. Now if mycall is a standalone function at global scope, you could call it as long as you have a variable named private_data defined in an accessible scope to the call.
I'd recommend you spend some time with a good introductory book to C++.
Once you agree to clans, tribes, governments...you've opted for socialism. The rest is just details.
|
|
|
|
|
Tim Craig wrote: I'd recommend you spend some time with a good introductory book to C++.
Seconded. I'm not against people asking noob questions - after all we've worked our ways up from there.
But what irritates me is the fact that people don't even want to learn the VERY FUNDAMENTALS of programming (I'm sure a book would clear things up enough for them to ask meaningful questions).
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|
|
It was just a general question
if a Call from the global scope within a method of that class can reference provate data of that class
Just tried to gove a example of what i was talking about
didn't mean it would compile
|
|
|
|
|
And I explained it as best I could given your question and the snippet you gave.
Once you agree to clans, tribes, governments...you've opted for socialism. The rest is just details.
|
|
|
|
|
Assuming that you are asking if you, from your own class, can use your class private data as arguments to a global function, the answer is yes.
|
|
|
|
|
|
ForNow wrote: Many times I have seen :: followed by Windows API without a class name on the left does that mean that the API doesn't exist
Well, that :: is an operator and is called as the scope resolution operator[^].
Assume you were writing MFC code. If you try to display a message box by just typing MessageBox, the CWnd::MessageBox()[^] will be called by default, because the MessageBox call is redefined within MFC. And hence you make the call within MFC, the call won't reach out of it. If you want to call the Win32 message box instead, you would say ::MessageBox()[^] which would call the api at global scope. The rationale behind calling the global message box here might be the you don't want the program flow to be blocked (calling the mfc version uses the same message pump as the program for displaying the message, so the execution will be blocked until the message box is dismissed).
Hope that helps.
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|
|
its more of Asyncrous call sort of like PostMessage
|
|
|
|
|
Only in the example he cited. Normally, it's used where you have a class method with the same name as a global function, actually the same signature and you want to call the global one rather than the member. Another reason, is just to make sure it's clear you meant to call the global one to make it easy on maintenance programmers. If there's no ambiguity, you really don't need to use the scope resolution operator as the compiler can tell what you meant, the global function is the only match for the call. The flip side is that if you wanted to show you really meant to call the internal method, you could prefix it with this-> to show your intention although it isn't necessary.
Once you agree to clans, tribes, governments...you've opted for socialism. The rest is just details.
|
|
|
|
|
Hello people!
I'd like to study some OLE programming in VC++. I have a basic knowledge of COM and i know so about the concept of OLE itself. I tried to google around for tutorials or documentation but what mostly turns up is either articles describing what OLE is (so no technical details about actually implementing it), articles about how to insert OLE objects into excel/word documents, articles about how to do this programatically in VB.NET, and so on... What i would like to know is how to go about creating my own OLE objects that can be inserted into a word document, or excel or whatever that provides support for OLE. This info must be out there and i am probably just looking for the wrong terms but my knowledge of the whole concept is too limited to actually know what to look for.
So if any of you knows a good place to start, please share, thanks in advance.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
See here[^], I would suggest you take particular note of the statement towards the bottom of the page that states:
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
It's time for a new signature.
|
|
|
|
|
So you mean OLE is actually a thing of the past? Damn, i am older than i thought, then what is used nowadays? Would it be ActiveX?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
modified on Friday, June 25, 2010 9:11 AM
|
|
|
|
|
I'm not too sure, it's not a technology I ever got into, but I think it was superceded by ActiveX. However, if you are wanting to get into new technology I think .NET, WPF etc may be better choices.
It's time for a new signature.
|
|
|
|
|
I think i will check around ActiveX to see if i can use it. Using .NET and WPF is planned for the future...
Thank you for the help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
See if you can find a second hand copy of "Inside OLE2" by Craig Brocksmidt. The details about COM in there are pretty dated but you should be able to spot those. The bulk of the book talks about the interfaces you have to implement to support OLE and is still surprisingly current.
Admittedly every time I read the book these days I wonder how the hell anyone ever thought OLE or COM were good ideas...
Cheers,
Ash
|
|
|
|
|
I thought the implementation of Ole was always a crappy idea...
Once you agree to clans, tribes, governments...you've opted for socialism. The rest is just details.
|
|
|
|
|
Thanks, i'll try.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Aescleal wrote: wonder how the hell anyone ever thought OLE or COM were good ideas...
They were good ideas. COM is about making language independent binary components and done a good job. OLE is admittedly complicated but the there's no simple solution to the problem it was trying to solve (object linking and embedding).
Steve
|
|
|
|
|
A function takes stream as input argument
functionname(LPUNKNOWN pStream)
I have character array and i need to use that function. How should i convert my array to LPUNKNOWN pStream
|
|
|
|
|
Typecast..
char arrc[10];
functionName((LPUNKNOWN) arrc);
|
|
|
|
|
I TRIED THE SAME BUT WHEN I CALL FUNCTION IT GIVES EXCEPTION.
|
|
|
|