- Strength to Increase Rep
- +3
- Strength to Decrease Rep
- -0
- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
11 Posted Topics
The differences I think are in that, with data-members declared public, the user(the code which instantiates/uses this class) has to totally manipulate the data-members by itself.. e.g. [CODE] class Rect { public: int w, h; int area; }; [/CODE] In above code, if user wants to know the area, he …
@Corby, Assuming the followig Package.h, it worked fine for me.. started taking input from sender's name to receiver's zip code, and then outputted data in proper format too, though i had to add main function to the cpp file because yours is not visible in the code you submitted.. Let's …
@gregarion, I'm not sure what you're trying to do with the array str.. But I guess your goal was to find the number of occurence of certain characters in the array str. But that won't be given by find function. size_t find ( const char* s, size_t pos, size_t n …
@dmr215, please provide the code which you say is almost working. This code is far from even compiling let alone execution. Another observation is that this code's written a lot from the POV of java(don't know about PHP as i've never used that.) e.g. 1. unlike java, in C++ all …
Here's the corrected code.. Your problem mainly was that you hadn't put indexes while using your arrays.. rest is almost the same.. I almost did indent the code as otherwise it was impossible to understand. [code] #include<iostream> #include<string> using namespace std; enum Identification { Idstudent, Idworker, Idstudentworker }; class person …
I completely agreew with Banfa' explanation.. Something like this should do: [code] Term& Term::operator +=(const Term &t) { if (exponent == t.exponent) { coefficient += t.coefficient; //exponent = t.exponent; // it's basically a redundant statement as exponent = t.exponent as per the if condition } // Don't forget to add …
How about: [CODE] max = max2 = first while not eof do if value > max then max2 := max max := value else if value > max2 then max2 := value end if loop [/CODE]
e.g. [CODE] class B { public: virtual ~B() {printf("Base class Destructor");} }; class D { public: ~D() {printf("Derived class Destructor");} }; [/CODE] Is it somehow possible to altogether avoid printing 'Base class Destructor' when an object of class D is destructed (of course without causing a memory leak).. If you …
[code] template <typename T, int m, int n, int p> Matrix<T, m, p> operator *(const Matrix<T, m, n>& A, const Matrix<T, n, p>& B) { Matrix<T, m, p> ret; for (int i = 0; i < m; i++) for (int j = 0; j < p; j++) { ret[i][j] = …
class A { A& a; public: A(): a(* new A()) {} }; There is a huge flaw here and before I compiled this code I was hoping that it will fail to compile, But it didn't. At first I felt like I had a big flaw in C++ as it …
After looking at other posts and warnings, I have edited this post so as to remove half of the functions, so the person who started the thread has to do some of the work himself [CODE] /** * file name: charRoutines.cpp * author: Nitin Garg */ #include "charRoutines.h" #define NUM_CHARS …
The End.
tintin.iitk