Questions Regarding the Literal C++ Coding Language

Hello and thank you! I'm sorry for my title if it is a bit confusing. What I'm trying to ask is very quite literally how to code in C++. Let me explain. I read a book to learn C++ and I never came across a few things that I did while reading some example code for something. And I found myself a little baffled. So I request aid.
First, here is the structure for something called Overlapped
1
2
3
4
5
6
7
typedef struct _OVERLAPPED {
    DWORD Internal;
    DWORD InternalHigh;
    DWORD Offset;
    DWORD OffsetHigh;
    HANDLE hEvent;
} OVERLAPPED, *LPOVERLAPPED;

So firstly, it is saying typedef but I don't see the type it is defining. I.e.
typedef unsigned int UINT;
Second, what the heck are OVERLAPPED, *LPOVERLAPPED.
http://www.cplusplus.com/doc/tutorial/structures/
According to the link above, they are objects that are created right from the get go. But that doesn't seem right.

Second,
1
2
3
4
5
6
class simpleRunnable: public Runnable {
public:
	...
	virtual void* run() {
	...
};

What does the colon after simpleRunnable mean?

It is similar to the following code but I'm not sure if the colon is being used with the same context. So if it is different, I appreciate being told what the colon after the function name below means:
1
2
3
SimpleCat::SimpleCat(int age, int weight):
itsAge(age), itsWeight(weight) //Please note, itsAge and itsWeight are variables in the class declaration
{}


Next, in the following line,
 
std::auto_ptr<Runnable> r(new simpleRunnable(1));

What do the angle brackets mean?

And finally, I often see this (that is to say, I'm refering to the word, WINAPI:
1
2
3
4
unsigned WINAPI Thread::startThread(LPVOID pVoid) {
	Thread* aThread = static_cast<Thread*>(pVoid);
	....
}

The other variation I see is CALLBACK. I actually found what CALLBACK means which, if I have it correct, is only used when there are multiple threads and it is simply used to "call back" the function that called it when a task will take some time to complete or its processing time runs out.
But when I looked up WINAPI, I just got definitions and stuff.
Last edited on
anonymousxyz wrote:
First, here is the structure for something called Overlapped
1
2
3
4
5
6
7
typedef struct _OVERLAPPED {
    DWORD Internal;
    DWORD InternalHigh;
    DWORD Offset;
    DWORD OffsetHigh;
    HANDLE hEvent;
} OVERLAPPED, *LPOVERLAPPED;

So firstly, it is saying typedef but I don't see the type it is defining. I.e.
typedef unsigned int UINT;
Second, what the heck are OVERLAPPED, *LPOVERLAPPED.
http://www.cplusplus.com/doc/tutorial/structures/
According to the link above, they are objects that are created right from the get go. But that doesn't seem right.
1
2
3
4
5
6
7
8
9
typedef /*type*/ OVERLAPPED, *LPOVERLAPPED;
//where /*type*/ is:
struct _OVERLAPPED {
    DWORD Internal;
    DWORD InternalHigh;
    DWORD Offset;
    DWORD OffsetHigh;
    HANDLE hEvent;
}
anonymousxyz wrote:
Second,
1
2
3
4
5
6
class simpleRunnable: public Runnable {
public:
	...
	virtual void* run() {
	...
};

What does the colon after simpleRunnable mean?

It is similar to the following code but I'm not sure if the colon is being used with the same context. So if it is different, I appreciate being told what the colon after the function name below means:
1
2
3
SimpleCat::SimpleCat(int age, int weight):
itsAge(age), itsWeight(weight) //Please note, itsAge and itsWeight are variables in the class declaration
{}
A colon after a class name like that means 'inherits from'. A colon after a constructor is just the initializer list.
anonymousxyz wrote:
Next, in the following line,
 
std::auto_ptr<Runnable> r(new simpleRunnable(1));

What do the angle brackets mean?
Read up on 'templates'.
anonymousxyz wrote:
And finally, I often see this (that is to say, I'm refering to the word, WINAPI:
1
2
3
4
unsigned WINAPI Thread::startThread(LPVOID pVoid) {
	Thread* aThread = static_cast<Thread*>(pVoid);
	....
}

The other variation I see is CALLBACK. I actually found what CALLBACK means which, if I have it correct, is only used when there are multiple threads and it is simply used to "call back" the function that called it when a task will take some time to complete or its processing time runs out.
But when I looked up WINAPI, I just got definitions and stuff.
I don't know what your question is, but your idea of what CALLBACK is is wrong.
Last edited on
@L B
Thank you very much! And sorry for forgetting the actual question for the last thing.
It was simple: What does the WINAPI refer to, and in general, what does a word inbetween the return type and function name actually mean?
anonymousxyz wrote:
What does the WINAPI refer to, and in general, what does a word inbetween the return type and function name actually mean?
WINAPI and CALLBACK are macro definitions that are replaced by the calling convention. Look up "calling conventions".
Topic archived. No new replies allowed.