C++ Quiz no.1

The next posts will include C++ related stuff due to the current Mazonka-based mentoring. Here is a simple quiz to start with:

Is there something wrong with the following code? If yes, can you explain why?

{
 const int c = 1;
 int * p;
 const int ** q = &p; // q points to p
 *q = &c; // now p points to c
 *p = 10; // modify c !
}

Answer will be provided to the next post.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s