Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bronxbomber92

macrumors regular
Original poster
Nov 23, 2006
109
0
Hello, recently I was presented with this test that covers very various details of C++. I found myself not knowing most of the answers, but I did fair well, considering I've only known C++ for a few months. I would like to improve myself, and try to learn about potential pitfalls, optimization, and other fine details of C++. The test is as following, to provide what some information of what i cam talking about. Please keep in mind, I'm not talking about these question in specific, just anything similar to these.

Edit - "Test" has been taken out

So, any sites, or resources that has good information would be highly appreciated!

Thanks,
Jedd
 

superbovine

macrumors 68030
Nov 7, 2003
2,872
0
Hello, recently I was presented with this test that covers very various details of C++. I found myself not knowing most of the answers, but I did fair well, considering I've only known C++ for a few months. I would like to improve myself, and try to learn about potential pitfalls, optimization, and other fine details of C++. The test is as following, to provide what some information of what i cam talking about. Please keep in mind, I'm not talking about these question in specific, just anything similar to these.

Please don't post this any where else, I would like to keep it contained :)
Thanks


So, any sites, or resources that has good information would be highly appreciated!

Thanks,
Jedd


I think this was my c++ final in college.



* What is the difference between between a const global variable and a #define? Where would you use one over the other?

const is a c++ construct that makes a variable constant and unable to change. The difference is it provides strong compile time checking.

* Difference between:
const int * const foo->const pointer integer
const int * foo->pointer integer
int * const foo->const integer pointer



* What is the difference between a recursive function and loops? Give an example of each.
recursive is a function that call itself. There is some math definition, but hell if i remember it.

* Write a bubble sort function
void BubbleSort (int * IntArray, const unsigned int ArraySize)
{
google bubble
}

* What errors would occur in the following code and why?

class Blah
{
private:
int Foo;

public:
Blah() { Foo = 10; }
~Blah() {}
MyFunction ( int &Mobor)
{
Mobor += 10;
}
};

int main( int argc, char **argv)
{
Blah * ptr = 0;
ptr->MyFunction(10);
return 0;
}

calling a method in class that hasn't been instantiated and is isn't a native c++ type. You probably need void in front of my function.

* What does a static variable do in a function?
variables get set and compile time. so when you run your software the static variables are already in memory.

* What is a ring buffer and how does a it differ from a standard queue?
i think a ring buffer is a circular queue which means there is pointer at the points back to the other end.
* What does "in place" mean (regarding algorithms)? Give an example.
no idea

* What are the differences between an Octree, Quadtree and a BSP? What can they be used for?
bsp stores branches of a polygon i believe. I don't what the others do

* Optimise this function:
const int Sum (const int * LotsOfNumbers, const unsigned int Size )
{
int Sum = 0;

for(int i = 0; i < Size; ++i)
{
Sum += LotsOfNumbers[ i ];
}

return Sum;
}

optimize in terms of what?

* The difference between ++i and i++;
++i is run before the line is executed.
i++ is run after.

* Describe a use of a function pointer and suggest other methods to produce the same effect.
pointer is a memory address. it sort of a stupid question.

* What is a template class? What an example that stores an object with a function that squares itself returning the object as a const. Give an example why this would not work with all objects.

i don't the definition.

* What is the difference between an Interface class and an Abstract class?
good question

* What is wrong with the following piece of code and how would you fix it? What would be the result of the error and

why?

class A
{
private:
int *AInt;
public:
A() { AInt = new int(0); } //int nTemp = 0; AInt = &nTemp;
~A() { delete AInt; } // {}
};

class B : public A //class B
{
private:
int *BInt;
public:
B() { BInt = new int(0); }//int nTemp = 0; AInt = &nTemp;
~B() { delete BInt; } //{}
};
 

notjustjay

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
Google is your friend. For programming related questions and discussion, Google Groups is often better than the web search.

If you want to kick start some discussion, why don't you post some of the answers you gave, and for questions you didn't know how to answer, maybe run through some of your thoughts, best guesses, etc. That way we won't feel like we're doing someone's homework for them, and you'll give people an idea of what you already know.

But I say again, Google is your friend. C++ programming is my profession now, and I use Google to look stuff up just about every day.
 

bronxbomber92

macrumors regular
Original poster
Nov 23, 2006
109
0
Dang, my friend who gave this "self test" Ino, it wasn't homework), requests me not to share it. So I have to edit the post, and superbovine, if you could edit the questions out, I would appreciate it.

Thanks for your suggestion notjustjay, I never thougt of Google groups. Also, I recently found that the book I've been reading isn't the most "informative" book one could buy. Perphaps i should get a different book :p

Thanks for the comments :)
 

superbovine

macrumors 68030
Nov 7, 2003
2,872
0
Dang, my friend who gave this "self test" Ino, it wasn't homework), requests me not to share it. So I have to edit the post, and superbovine, if you could edit the questions out, I would appreciate it.

Thanks for your suggestion notjustjay, I never thougt of Google groups. Also, I recently found that the book I've been reading isn't the most "informative" book one could buy. Perphaps i should get a different book :p

Thanks for the comments :)

by friend I am sure you mean your professor.
 

notjustjay

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
Please don't take any "doing your homework for you" comments personally. I've just been around forums and Usenet groups (e.g. Google Groups) long enough to have seen some pretty thinly-disguised requests.

As for books, I'm generally very happy with anything published by O'Reilly and Associates (the books with the random animals on the covers).

Happy learning!
 

bronxbomber92

macrumors regular
Original poster
Nov 23, 2006
109
0
I don't take it personal, but this isn't homework.... My "friend", is someone who works for EA. I have the answers to these. I wasn't asking for answers, I was just looking for resources that provided similar like information to learn upon.

Btw, this is EA developer... http://forums.evilmana.com/index.php?topic=282.msg3141#msg3141

I can also show you him giving it to me. I just need to take a screenshot of the thread, as it's in the moderator forum.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.