- Strength to Increase Rep
- +2
- 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
Re: 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 … | |
Re: @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 … | |
Re: @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 … | |
Re: @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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: Corresponding C++ code. :) #include <cstdlib> #include <iostream> #include <iomanip> #define SYSTEM_OUT_PRINTLN(x) {cout << x << endl;} namespace scratchpad { class Comparable { virtual int compareTo(const Comparable& other) = 0; }; class Integer: public Comparable { public: Integer(int i = 0) {val = i;} int compareTo(const Comparable& other) { return … |