- What is a void return type?
- How is it possible for two String objects with identical values not to be equal under the == operator?
- What is the difference between a while statement and a do statement?
- Can a for statement loop indefinitely?
- How do you link a C++ program to C functions?
- How can you tell what shell you are running on UNIX system?
- How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
- How do you write a function that can reverse a linked-list?
- Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
- What is a local class?
- What is a nested class?
- What are the access privileges in C++? What is the default access level?
- What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages?
- How do you access the static member of a class?
- What does extern int func(int *, Foo) accomplish?
Posted in: C++ |
October 4th, 2007 at 9:30 am
for question no 6:
we can find out the shell which we are currently working is in terminal we have like[bash/abc/home] here bash is the shell. so that you can find out like tat.
October 4th, 2007 at 9:32 am
question 12:
you have 3 access modifiers in C++ 1. private 2. public 3. protected. defaultly c++ variable are Private. Java variables arr Public. C# varibles are Virtual
October 4th, 2007 at 9:34 am
14:
you can use the static memeber or method of a class in Main function jus call class name. method or member name. tats enough
October 4th, 2007 at 9:35 am
15:
we can use the Extern keyword function in any other file. we can call that function indepedently
October 15th, 2007 at 11:44 pm
Question:1
void doesn’t return any value
Question:2
By using an operator overloading we find the strings are same or not
Question:3
while check the condition in entry,do-while check the condition at exit of the loop statement ie., do-while works atleast once
October 26th, 2007 at 3:45 am
12. What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages?
October 30th, 2007 at 6:03 am
What is a local class?
If a class is defined within a function that class is a local class which is local to the function and it can not be accessed outside the class.
October 30th, 2007 at 6:04 am
Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
Yes it can accept but it will go on infinite loop.
October 30th, 2007 at 6:07 am
What is a nested class?
Class within a class.
How do you access the static member of a class?
static data member -you can access thru member function or thru class name using scope resolution operator.
static member function:-you can access thru class name using scope resolution operator.
November 5th, 2007 at 4:29 am
4. Can a for statement loop indefinitely?
YES, leave conditional expression blank ie. in the format
for(i=0;;i++)
November 5th, 2007 at 5:08 am
How do you write a function that can reverse a linked-list?
Ans:
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur->next = head;
for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
November 29th, 2007 at 3:25 am
Q. #5
You can do that by means of the
extern "C" { }
construct.Q. #6
Easy, you could use the getenv function, like this:
#include
#include
int main(){
std::cout
Q. #7
Many ways to implement it, but you could basically add a counter to each node with initial value of 0, then after each node read increase its value, so before reading you compare if it has the same value or higher than the previous node then we’ve found a loop, if not (value = prev - 1), then increase the value counter + 1.
Q. #9
Depends on the compiler, whoever, the definition of copy constructor explicitly says that it can only have an const-reference of the same class as argument.
Q. #12
The access privileges are public, private and protected. public can be accessed from any subclass and even outside the scope of the class, protected can only be used from within the scope of the class and its subclasses, private can only be used within the scope of that class but is forbidden for any subclass. The default access privilege is private.
December 12th, 2007 at 8:57 pm
#13
In a diamond hierarchy, virtual inheritance allows a derive class “D” to share only one copy of the common base case “A”. This is done by using the keyword virtual on the declaration.
For example
class A{…}
class B : virtual public A {…}
class C : virtual public A {…}
class D : public B, public C {} // class D only contains one copy of A.
Advantage: The derived class contains only one copy of the base class.
Disadvantage: The runtime cost is similar to the one of a virtual function. The compiler inserts a pointer (in D) that points to the location of the base “A”. And it has to dereference it, whenever is needed.
December 13th, 2007 at 2:04 am
What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages?
Multiple Inheritance means there is only one base class and multiple no. of derived class are inheriting it.
Virtual Inheritance: Suppose class A is inherited by class B and class C. Another class D is inheriting class B and C. Now class D is indirectly inheriting class A that to two times. This is an ambiguity. To avoid this we have amke the class A as Virtual base class and class B and C will have inherit is virtually. Now when D is inheriting both B and C, it will get only one copy of A rather than 2 copies(as in the earlier case). This virtual Inheritance.
December 28th, 2007 at 2:52 am
3.What is the difference between a while statement and a do statement?
Ans:
while is first check the condition and execute the statements
but do first execute the statements then check the condition
January 14th, 2008 at 4:34 am
Q: What is a void return type?
A: void return type indicates that the function returns nothing ( no value at all ). Although this should not be confused with the ” void * ” return type which is altogather different thing.
Q: How is it possible for two String objects with identical values not to be equal under the == operator?
A :
Q : What is the difference between a while statement and a do statement?
A : While checks the condition statement before the iteration whereas do checks the conditon statement after iteration.Thus do ensures that the loop block is executed at least once.
Q : Can a for statement loop indefinitely?
A : Yes . for (int i=0;i!=1;) cout
February 29th, 2008 at 6:58 am
How do you find out if a linked-list has an end?
Check the next(pointer) of each node, if it is NULL that is the end node. Linked list will be a loop if there is no NULL value in any of the node’s pointer.
March 11th, 2008 at 3:07 pm
Hi
i wanna to ask aquistion , i’m try to do a programe to read from file expretion like this(create x [10,20,30]) and simulate it in c++ cod here is my cod ,i’d be gratiful if any body help me to solve this problem.
//******************************************/
#include
#include
#include
using namespace std;
class MemoryTableEntry{
public :
char vn;
vector* list; //eh da?
};class parser(){ MemoryTableEntry memroyTable[100];
static int variable_index = 0; void parse(string str){
if(c==create){ char vn=’x'; vector* v=new vector(); MemoryTableEntry entry;
entry.vn = vn;
enrty.list = v;
memroyTable[variable_index] = entry;
variable_index++;
}
}
};
void main(){
fstream f1("F://f1.txt");
char c;
while(!f1.eof()){
f1>>c;
cout<