Open main menu

CDOT Wiki β

Team 42 Contributions

Revision as of 23:29, 18 November 2012 by Kirill Sochnev (talk | contribs)

C/C++ FAQ


Q: Can a functional pointer be used to point to an overloaded function? If so, which function will it call when the pointer is dereferenced and why?
Question Submitted by: Gideon Thomas and Marie Karimizadeh

A:Function Pointer can be used to point to any function with the same signature as its own.
"Signature is the information about a function that participates in overload resolution: its parameter-type-list... Function signatures do not include return type, because that does not participate in overload resolution." (Working Draft, Standard for Programming Language C++ 2005-10-19, p3, 1.3.11 signature)
In the case of overloaded functions the only thing they have in common is the name. Signatures are different, hence the same pointer to function can't be used for both of them.

Back to your question. Call to Function Pointer will call an overloaded function with the same signature as the Function Pointer.
Answer Submitted by: Team42


Q: How to visualize a multi-dimensional array?
A: The simplest way to do so for a 2 dimensional array is a table

0123
4567
7890

It gets slightly more complex when it comes to 3 dimensional arrays

  • First what comes to minds of majority of people is a cube
            __________	
           /\444444444\
	  /\3\444444444\
	 /\2\3\444444444\
	/\1\2\3\444444444\
	\0\1\2\/33333333\/
	 \0\1\/22222222\/
	  \0\/11111111\/
	   \/00000000\/

(There are many disadvantages to using this form besides awkwardness!)


  • Another way is to display each of the layers as separate 2 dimensional arrays
111
111
111

222
222
222

333
333
333

To be Continued (Feel free to add your ideas! :D)

Submitted by Team42

Assignment 2


Q: Are we able to toggle the border's visibility or are we only able to toggle the frame's visibility? If yes, the constructor does not receive any information about the visibility of the border, do we assume that the border is visible?
Question Submitted by: Gideon Thomas and Marie Karimizadeh
A: Yes, we do get to toggle the border visibility by using the

 void bordered(bool);
method which "sets the visibility of the border to the value received". The frame has no border if it is a fullscreen frame, should be safe to assume it has a border if it is not fullscreen (unless otherwise specified).

Answer Submitted by: Team42

Q: In the functions void row(int) and void col(int), are we receiving the values of row and column respectively that are relative to the parent frame or relative to the console screen?
Question Submitted by: Gideon Thomas and Marie Karimizadeh
A: In a CFrame class description most modifiers came in pairs with queries, like

void row(int) - sets the top row to the value received

int row() const - returns the top row position relative to the parent frame, if any; 0 if fullsreen



void col(int) - sets the left column to the value received

int col() const - returns the left column position relative to the parent frame, if any; 0 if fullsreen

So it's safe to assume that modifiers void row(int) and void col(int) will receive coordinates of top-left corner (row and col respectively) of the current frame relative to the parent frame.
Answer Submitted by: 010101000110010101100001011011010011010000110010


Q: Since we can have a potential of unlimited frames within frames, how can we tell how many frames are in the console? (how far down in the frames within frames)
Question Submitted by: Wesley Hamilton and Joe Higginson

A: You can use this simple function to calculate the number of parents within parents of the current frame:

int SomeClass::number_of_parents(){

    return (parent ? 1+parent->number_of_parents() : 0);

    //"parent" is a reference to the parent of the current frame

}

But you can't know how many children the current frame has, unless you create special class members to keep/calculate that number.
Answer Submitted by: Team0x2Au


Possible/Challenging Enhancements

  1. Smart word wrapping - words are not cut off mid-word while wrapping
  2. Optimization - "test" compiled executables have efficiency issues when moving boxes around
  3. Colors - you can add color to the test program if you're making your own main (Warning! Platform Dependent Code)
  4. Cursor Visibility - you can toggle the cursor visibility (Warning! Platform Dependent Code)
  5. Timer - to keep track of how long the user has been running your custom main
  6. Files - Read string from file, use that string for editing, then write the result string to that file, overwriting original
  7. Child Tracking - each frame keeps/updates number and an array of addresses of children frames within it.