C++ Viva Questions
Well, today I had my C++ viva at my school..and I screwed it up!! The answers to this question which I was asked may be easy but I couldn't get it..Few questions of which I haven't got the answers yet--
1. DaniWeb-Flavored Markdown Syntax
C++ Syntax (toggle plain text)
class A { public: int a; int b; };
In the class A there are two public members. If a pointer is created for the object of this class, it will point to first public member of this class. How would I be accessing the next member in the following cases--
1. if the object was static
2. dynamic object
3. normal object
2. How to access any element of two dimensional array using pointers .
3. I was also asked the output for this--
______________________________________________________________________________________________
#-Link-Snipped-# | #-Link-Snipped-# | #-Link-Snipped-#
1. DaniWeb-Flavored Markdown Syntax
C++ Syntax (toggle plain text)
- class A
- { public:
- int a;
- int b;
- };
class A { public: int a; int b; };
In the class A there are two public members. If a pointer is created for the object of this class, it will point to first public member of this class. How would I be accessing the next member in the following cases--
1. if the object was static
2. dynamic object
3. normal object
2. How to access any element of two dimensional array using pointers .
3. I was also asked the output for this--
______________________________________________________________________________________________
#-Link-Snipped-# | #-Link-Snipped-# | #-Link-Snipped-#
Replies
-
Manish Goyal2nd question 3rd part
whenever you create pointer to normal object
you can access its members by using
p->f.a;
p->f.b;
where p is pointer to object,,f is onject
For 3rd question
use this
*(*(a + i) + j)
to assign element to an array say 1 to s[1][1]
then you can use
*(*(a+1)+1)=1;
You are reading an archived discussion.
Related Posts
NASA selected three finalists to be the agency’s next cheap, robotic exploration mission. Depending on which wins, a probe will head for Venus, the moon, or a near-Earth object no...
Ads take over entire screen when you visit a website and intrusively play music, alerting everyone around you that you've visited a website that is probably not work-related and may...
Write a Program to check whether no is prime or not
without using
any /,% operator and If statement?
If anyone wants to share with us your lovely memories of 2009
then post it here
I hope most of you Guys have faced this attack many times but don't know about it
ie phishing attack
Phishing is a form of social engineering. Phishing attacks use...