462 Topics

Member Avatar for
Member Avatar for nullifyQQ

I have this weird problem. If my constructor is [header] class Book { private: vector<string>Entry; public: Book(); [cpp] Book::Book(){ Entry.push_back("0"); Entry.push_back("1"); Entry.push_back("2"); The weird thing is that it does not update when I do more .push_back. I use: void Book::addItem(vector<string>newItem) { for(int f=0; f<Entry.size(); f++) { Entry.push_back(newItem[f]); cout<<Entry[f]; } } …

Member Avatar for L7Sqr
0
291
Member Avatar for sciwizeh

Hello all, I have not tested the code I'm posting here to see if it compiles, but I have an issue in a large codebase and I believe that this should be the simplest program to demonstrate the issue; class base { public: shared_ptr<base> clone()=0; }; typedef shared_ptr<base> baseptr; class …

Member Avatar for sciwizeh
0
20K
Member Avatar for DarWar

Hi everyone! So I have this code to modify. I need to write a code inside the **int main** field, that would cause 37 launches of the constructor called M_48(). I have no idea how to solve this. Any ideas?

Member Avatar for deceptikon
0
195
Member Avatar for ibthevivin

So this is basically what's supposed to be the outcome of my code: > 69:hw/05/src> javac WordOccurrenceCounter.java 70:hw/05/src> java WordOccurrenceCounter Reading the book... Getting counts from a TreeMap... Enter a string ('q' to quit): wealth wealth occurred 7 times. Enter a string ('q' to quit): poverty poverty occurred 10 times. …

Member Avatar for Taywin
0
248
Member Avatar for rocksoad23

Hey, I'm developing a program in which there are two classes. The purpose of one of them is to create vectors that change dinamically (class A) and the other is a bunch of methods to operate on these vectors (class B). The question is: I don't see any need to …

Member Avatar for ravenous
0
148
Member Avatar for inaxassan

The human body has many organs (heart, lungs, brain, and kidney, to name a few). We could think of the human body as complex object made up of simpler objects (organ). a) Create classes for heart and brain. Think about what the functions of the heart and brain are in …

Member Avatar for TrustyTony
0
294
Member Avatar for szejna

Hello, I am working on a homework problem that has to do with inheritance, I thought that as long as the class interface and implementation files for the base classes the derived would work with the include statement: #include "salariedemployee.h" and the line class administrator : public salaried employee. I …

Member Avatar for szejna
0
264
Member Avatar for strava

I'm newbie in C++ programming and I want to declare a constructor from following code in my main however I'm completely confused about it. Here is the code: #include <vector> using namespace std; template <typename HashedObj> class HashTable { public: explicit HashTable( const HashedObj & notFound, int size = 101 …

Member Avatar for deceptikon
0
640
Member Avatar for rami sohaill

package hospitalclient; public class Person { static int idnumber= 1500; private String name; private String telephoneno; private char gender; private String nationality; //No Parameter constructor public Person() { name="unassigned"; telephoneno = ""; gender = 'M'; nationality = "Saudi"; } public int getid() { return idnumber; } // Accessor Methods public …

Member Avatar for JamesCherrill
0
349
Member Avatar for ogrishmania

I'm sort of a begginer in classes. I must implement a simple problem: chosing a phone. I thought that I should make a program in which a user can select some conditions, like must have wifi or not, android or other, etc. and return a list with the phones that …

Member Avatar for mrnutty
0
285
Member Avatar for thumati

i Always getting : **mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\class\function.php on line 28** please give the suggestion friends config.php <?php define('DB_SERVER', 'localhost'); define('DB_USERNAME', 'root'); define('DB_PASSWORD', '12345'); define('DB_DATABASE', 'class'); class db_class { function db_constractor() { $connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die('Oops connection error -> …

Member Avatar for tiggsy
0
270
Member Avatar for nicholas.buckley.14

I have to write a program that accepts data for a class and then ouputs it in the main. so far i have this. #include<iostream> #include<string> #include<fstream> using namespace std; ifstream infile; class animal { string species; string family; string phylum; string desc; static int count; public: bool readIN(const string …

Member Avatar for rstralberg
0
314
Member Avatar for challarao

Hi all, A problem asks me to create a point class,line class composing two points, a triangle class composing three lines.Also a right angle triangle and an equilateral triangle class both inherit triangle class.I did this. public class Point{ private int x; private int y; public Point(int x,int y){ //error …

Member Avatar for jalpesh_007
0
193
Member Avatar for MugANDGlass

can anyone help me? i got problem count the monthly installment. //class class vehicle { public: char model[20], color[20], brand[20]; float price, deposit, rate, monthly_installment, newprice; int term; public: void calculate_installment(); }; class car:public vehicle { private: float installment, newprice; public: void calculate_installment(); }; //main program #include <iostream> #include <string.h> …

Member Avatar for DeanMSands3
0
172
Member Avatar for CodyM

/*I'm having trouble creating a constructor for degree and *coeffs as well as properly creating the dynamic arrays for the coefficients of the 2 polynomials a and b. I'm just concerned about getting the correct values. My textbook only gives us eamples of constructos for eamples not well related to …

Member Avatar for CodyM
0
225
Member Avatar for jongiambi

Hi so I have a practice lab I am working on where I am asked to fill in the code. The program is supposed to take in two 3D points (x,y,z) and compute the distance between them. I have almosty all of the program finished im just stuck on how …

Member Avatar for rubberman
0
858
Member Avatar for sivate
Member Avatar for challarao

hi all, In the book "Programming Languages-Pragmatics" second edition by Michael l. Scott and Morgan Kaufmann, there is a sentence while explaining about copy constructor: "In recognition of this intent, a single-argument constructor in C++ is called a copy constructor." This is about the constructor of the form foo::foo(const foo& …

Member Avatar for mike_2000_17
0
1K
Member Avatar for challarao

Hi all, I came to know that in Java or c++, constructor is executed only after the allocation of space.... Then what does an implicit default constructor(in c++) or default constructor in Java does....? If we explicitly define our constructor then the initialization will be done according to our needs! …

Member Avatar for JamesCherrill
0
299
Member Avatar for sephzy

Hey there, Just hit a road block in my assignment. I won't concern you too much with the assignment itself but it's basically a number input operated menu with option's like "Display employee details" & "Input pay details." I'm up to a part where I need to get the section …

Member Avatar for JamesCherrill
0
326
Member Avatar for rahul.ch

<? super Animal> means animal or it's superclass only. Then why inside the method it's allowing to add Dog object even though it's a subclass of Animal? This program compiles and runs! import java.util.*; class Cat {} class Animal{Animal() {System.out.println("Animal constructor");}} class Dog extends Animal{Dog() {System.out.println("Dog constructor");}} public class GenericDemo5 …

Member Avatar for rahul.ch
0
335
Member Avatar for TIM_M_91

Ok So I have two classes that share the same instance variables, the variables have been declared in 'Dog', however I cannot seem to get the instances to work within my other class 'DogChorus'. Therefore what must I do to get the instances to work within 'DogChorus' constructors? The variables …

Member Avatar for skatamatic
0
245
Member Avatar for anisha.silva
Member Avatar for anisha.silva
0
96
Member Avatar for jongiambi

The question asks: Write and compile a C++ program that simulates the arrivals of airplanes at Regina airport. An airplane is represented using a C++ struct. Each plane belongs to an airline, such as United, and records the city from which it is arriving, for example Chicago. The airport is …

Member Avatar for WaltP
0
297
Member Avatar for rahul.ch

class Sample1 { Sample1() {System.out.println("Sample1 const"); } void doStuff(){System.out.println("sample1 dostuff"); } } class Sample2 extends Sample1 { Sample2() {System.out.println("Sample2 const"); } } public class Sample3 extends Sample2 { Sample3() {System.out.println("Sample3 const"); } public static void main(String r[]) { new Sample3().go(); } void go() { super.doStuff(); } } The output is: …

Member Avatar for rahul.ch
0
196
Member Avatar for krystosan

Hello, I want to know and understand how and when do we need to implement classes in our code, I have written a program in python just using functions but never feel the need of using classes, so I was thinking when we can create something without classes why do …

Member Avatar for krystosan
0
189
Member Avatar for Ja14

There is a lot more that is supposed to go with this. For now, I'm just trying to implement a class that uses a vector. Class is called ItemList, it's the header file. Main creates the object and attempts to add to the vector. Compiler doesn't recognize "list" as a …

Member Avatar for deceptikon
0
4K
Member Avatar for ibthevivin

My Java is pretty rough. So far I've completed one class of Java all the way up to basic array functions. I've asked my Professor to explain it, but he talks with so much jargon. Could someone explain to me why this program spits out the "24" when I run …

Member Avatar for richard89AZ
0
253
Member Avatar for mkaynutty

So I'm trying to right a code to output some simple data using classes. Everything works accept the retail price function. It's suppose to calculate and output the retail price but it only outputs 0 no matter what numbers I eneter. Can anyone give me some suggestions on how to …

Member Avatar for Ancient Dragon
0
181
Member Avatar for jongiambi

I am trying to implement a function sameMonth from a class to compare two user entered months. My class is declared in a header file "Date.h": #include <iostream> using namespace std; class Date { private: string month; int day; int year; public: Date(); Date(string aMonth, int aDay, int aYear); void …

Member Avatar for vijayan121
0
285

The End.