[algogeeks] C++ Doubts !!

2011-09-24 Thread Decipher
Q1) What does the compiler does if I declare a base class VIRTUAL ?? Q2) In the below test code , class A : public B, public C { }; The order of constructor invocation is : B C A but if C is virtual base class the it changes to : C B A Why ?? Q3) Write a macro that swaps any data given to it

Re: [algogeeks] C++ Doubts !!

2011-09-24 Thread Varun Nagpal
Dude google C++ Faqs. You will find all your answers. You can also buy some books 1. C++ Common Knowledge: Essential Intermediate Programming 2. Effective and More effective C++ 3. C++ gotchas On Sat, Sep 24, 2011 at 11:52 AM, Decipher ankurseth...@gmail.com wrote: Q1) What does the compiler

[algogeeks] C Doubts

2011-07-17 Thread Abhi
1.When I declare a variable as const then any subsequent assignment of it gives an error assignment of read only variable. Is a const variable treated as a read only variable? 2. #includestdio.h struct s1 { char a; }; char s2 { char b; int c; };

Re: [algogeeks] C Doubts

2011-07-17 Thread Harshal
1. Yes, you cannot modify a const variable. This itself means that it is read-only. 2.Google structure padding. It is done to make sure that variables start in memory at addresses that are a multiple of their size. This is more efficient at hardware level. 'char' (1 byte) variables can be byte

Re: [algogeeks] C Doubts

2011-07-17 Thread aditya kumar
1) you cannot change the const variable . 2) generally sizeof behaviour in case of structure is just undefined. Either it follows the summation of size of members or it uses padding concept ie in your example 4 byte each for character(1 byte for char rest of the 3 bytes is padded up) and 4 byte

Re: [algogeeks] C Doubts

2011-07-17 Thread Abhi
That was really helpful. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/KvxrTcPf104J. To post to this group, send email to algogeeks@googlegroups.com. To