462 Topics
| |
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]; } } … | |
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 … | |
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? | |
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. … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 -> … | |
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 … | |
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 … | |
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> … | |
/*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 … | |
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 … | |
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& … | |
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! … | |
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 … | |
<? 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 … | |
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 … | |
hi how do i create a contaer class for a processors in C#? | |
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 … | |
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: … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … |
The End.