Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
Unknown Quality Score

No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.

0 Endorsements
~2K People Reached
Favorite Forums
Favorite Tags
c++ x 28
c x 1
java x 1
Member Avatar for tennis

[CODE]#include "stdafx.h" #include<iostream> using namespace std; class A { public: A(){} void setdata(int s) {t=s;} int getdata(){return t;} protected: int t; }; class B: public A { public: B(){} }; void main() { A a; a.setdata(3); B b; cout<<b.getdata(); }[/CODE] Why I cannot get an output of 3 here? Can …

Member Avatar for Narue
0
101
Member Avatar for tennis

I got run-time error for the following code. I am just starting to get familiar with linked list. Can any one point out what's the problem here? thanks [CODE] #include "stdafx.h" #include<iostream> using namespace std; struct node { int data; node * next; }; node* buildonetwothree() { node* head=NULL; node* …

Member Avatar for gerard4143
0
132
Member Avatar for tennis

I got run-time error in the following simple code, but I don't know what's the problem. can any one help? [CODE] #include "stdafx.h" #include<iostream> using namespace std; void reverse (char * source) { int i=0, j=strlen(source)-1; while (i<j) {char temp=source[j]; source[j]=source[i]; source[i]=temp; i++; j--; } cout<<source<<endl; } void main() { …

Member Avatar for rje7
0
130
Member Avatar for tennis

say iter1 and iter2 are both iterators [CODE]*iter1++=*iter2++;[/CODE] what does this line means? Can anybody help explain? ++ and * which is done first? thanks

Member Avatar for Duki
0
89
Member Avatar for tennis

I am not familiar with Java, but I have a question about a Java code which is supposed to find the first non-repeat element in an array. [CODE] Hashtable<Integer, Boolean> positions = new Hashtable<Integer,Boolean>(); int[] elements = {2, 2, 4, 5, 1, 6, 0, 9, 1, 4, 5, 10}; for(int …

Member Avatar for NormR1
0
85
Member Avatar for tennis

[CODE]// pointers to base class #include <iostream> using namespace std; class CPolygon { protected: int width, height; public: void set_values (int a, int b) { width=a; height=b; } }; class CRectangle: public CPolygon { public: int area () { return (width * height); } }; class CTriangle: public CPolygon { …

Member Avatar for sfuo
0
122
Member Avatar for tennis
Member Avatar for tennis

[CODE]Class date{ protected: int year_; int month_; int day_; public: date(); date(const int& d, const int& m, const int& y); date operator++(); //prefix operator date operator++(int); //postfix operator date operator--(); //prefix operator date operator--(int); //postfix operator }; date date::operator++(int){ //postfix operator return current value date d=*this; *this=next_date(d); return d; } …

Member Avatar for webweb2
0
75
Member Avatar for tennis

If I declared a static variable in a header file, and the header file is included in a couple of .c files. Is there any problem? Thanks

Member Avatar for Nick Evan
0
86
Member Avatar for tennis

If I declared a static variable in a header file, and the header file is included in a couple of .c files. Is there any problem? Thanks

Member Avatar for mike_2000_17
0
194
Member Avatar for tennis
Member Avatar for tennis
Member Avatar for tennis

1. an int and a class with only an int member, are they of the same size? 2. what is the size of a class containing 4 ints and a virtual function?

Member Avatar for Radical Edward
0
133
Member Avatar for tennis

In the following code, why x=new int; y=new int; are a must, if I comment out these two then I will have run-time error. I think I have int * x; and int* y; already shows that x and y are pointers point to int. There is no need to …

Member Avatar for VernonDozier
0
122
Member Avatar for tennis

I saw the following sentences from a book “A difference between a destructor and other member functions is that, if a regular member function has a body at the derived class, only the version at Derived class gets executed. Whereas in case of destructors, both derived as well as base …

Member Avatar for mrnutty
0
105
Member Avatar for tennis

I am not quite sure if I understand the meaning of the question very well I am thinking the answer is yes since we can use dynamic binding? Is this the right answer? Thanks

Member Avatar for Narue
0
77
Member Avatar for tennis

in c++ primer " [CODE]void reset(int *ip) { *ip = 0; ip = 0; }[/CODE] After a call to reset, the argument is unchanged but the object to which the argument points will be 0:" I understand that the argument is unchanged, but why the object to which the argument …

Member Avatar for Fbody
0
101
Member Avatar for tennis

In the following program, why there is no delete in the destructor? is it because there is no pointer involved, so no memory needs to be released? How about the memory allocated when constructing M,P,S,N, the memory will be release automatically when the program ends? Thanks [CODE]#include<iostream.h> class point { …

Member Avatar for Fbody
0
240
Member Avatar for tennis

In this class, line 3 "char * pName" and last line "char * name" pName and name are pointers or strings? I think they are pointers but if they are pointers how can we do strlen(pName) and strcpy(name,pName) in the code? Thanks class student { public: student(char * pName="no name",int …

Member Avatar for jonsca
0
134
Member Avatar for tennis

Struct Day { explicit Day(int d) : val(d) {} int val; }; what does the colon in the 3rd line means? Thanks

Member Avatar for jonsca
0
103
Member Avatar for tennis

[code] class TextBlock { pulic: ... const char& operator[] (std:size_t position) const {return text[position];} char& operator[] (std:size_t position) {return text[position];} private: std::string text; }; [/code] for the member functions why the return type is reference to char char& instead of char? return text[position] is a char for sure,not an address, …

Member Avatar for mrnutty
0
105