128 Topics

Member Avatar for
Member Avatar for xHellghostx

For example let's say we have the property called Customer that returns a value of name String name; <== Global Variable public String getName() { return name; } public String setName(holdingName) { name=holdingName; } and a constructor called Match public FullName(String realName) { holdingName = realName; } Can I do …

Member Avatar for stultuske
0
313
Member Avatar for xHellghostx

So I am working on a program and it has two seperate classes.. One of them contain the forum layout and the other contain some calculations and totals.. The problem is that the class with the calculations contain a constructor and other functions that I need to pass from this …

Member Avatar for tinstaafl
0
305
Member Avatar for phfilly

Hi all! I just have a quick question about the execution of a copy constructor. This is the code i'm testing my work with as I'm busy learning for a test. Class file: Clock :: Clock (int h, int m, int s) { hr = h; min = m; sec …

Member Avatar for can-mohan
0
289
Member Avatar for ambageo

Hi! I am supposed to write a programm for making a window.First of all, I must make a window with some given default values. Below is the code that I have been given as a template public class Window { private String name; private int height; private int width; private …

Member Avatar for ambageo
0
207
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
193
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
246
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
147
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 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 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
212
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
295
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
195
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
250
Member Avatar for jongiambi

Can anyone help me with this constructor problem? In main: instantiate one date object (date1) using the default constructor just to see that the constructor works, print the month, day, and year of date1 using the getters get input from the user and use the setters to set the values …

Member Avatar for jongiambi
0
401
Member Avatar for daino

My initial thoughts on the default constructor are that it was called automatically. From what I can see, it seems that this is so but a constructor called automatically doesn't initialize int or char variables for exampe, to Zero as I originally thought. It appears that they initialize the variable …

Member Avatar for vijayan121
0
293
Member Avatar for klin1344

Hi. I am a very beginner at Java. I am taking an online course on Java and I'm stuck on an assignment. Anyone who is good with Java, can you please take a look at my code? This assignment was due yesterday but I couldn't finish it. It is very …

Member Avatar for JamesCherrill
0
702
Member Avatar for Pyler

I wanted to write a simple program that uses classes but I've been running into errors. Anyone have a clue as to what is wrong with my code because I can't seem to figure it out. #include <iostream> #include <iomanip> #include <cmath> using namespace std; class cone{ private: double radius; …

Member Avatar for Rashakil Fol
0
248
Member Avatar for grh1107

currently I'm rewriting old euler solutions into classes so i can store them in a library. I wrote a program that digitizes a number so it can check to see if it a pallindrome, The base class digitize dynamically allocates memory for the size of a number and stores each …

Member Avatar for mike_2000_17
0
247
Member Avatar for naiiimah

I am trying to get this class put together but I've always had trouble figuring out constructors. I don't know what to set the data fields in Customer(int customerID, int checkoutTime, int arrivalTime){} // DO NOT ADD NEW METHODS OR DATA FIELDS! class Customer { private int customerID; private int …

Member Avatar for NormR1
0
197
Member Avatar for stupendousomega

Without the name, it runs fine. I read up that adding const before new could solve my problem, but it doesn't. Any ideas? include <iostream> include <string.h> using namespace std; class Player { int Health, *Strength, *Speed, *Accuracy, *Defense; char *Name[80]; public: Player (char, int, int, int, int, int); ~Player …

Member Avatar for raptr_dflo
0
160
Member Avatar for corvenzo

Hi, I'm a pretty new Java student and I was just confused on a few basic concepts. What exactly is the difference between public and private classes and in which case would you use each one? also, what is a constructor, mutator, or accessor? Thank you.

Member Avatar for ash.28.88
0
386
Member Avatar for lastbencher

Program: #include <iostream> using namespace std; class Rectangle { float len; float bre; public: Rectangle() {cout << "Rectangle constructed!" << endl; len=0; bre=0;} ~Rectangle() {cout << "Rectangle destructed!" << endl;} void setL(float L) {len=L;} void setB(float B) {bre=B;} friend float area(Rectangle rect); }; float area(Rectangle rect) { return rect.len*rect.bre; } …

Member Avatar for JasonHippy
0
166
Member Avatar for mags11

I am trying to figure out this one out. The directions: Write a class named car in the following fields: [LIST=1] [*]yearModel - The yearModel field is an int that holds the car's yea model. [*]make - The make field references a String object that holds the make of the …

Member Avatar for stultuske
0
12K
Member Avatar for 3nrichedd

Working on this program that uses 2 classes and a client program to test them, I keep getting this error pointing at my constructor, not sure what i am doing wrong but could use some assistance if anyone is able to offer, the error i am getting is: cannot find …

Member Avatar for stultuske
0
205
Member Avatar for emidevil

Hi. im kinda new here . i just want some help with this code i cant seem to figure out my problem, i already declared a constructor but it keeps on saying cannot find symbol when i compile it -_- import javax.swing.JOptionPane; import java.io.*; public class Sample_Thread { public static …

Member Avatar for DavidKroukamp
0
567
Member Avatar for 3nrichedd

I am working on this assignment in my java class, and am running into a few problems. Basically there are 2 classes and a main/client program that tests the classes. there is 1 superclass and a subclass that extends the superclass.. I have 2 constructors in my superclass but when …

Member Avatar for hiddepolen
0
250
Member Avatar for Eragah

[B][I]Hi I wanted to ask a quick question. I have two classes. And within my main class i am able to pass in variable to three variables EyeColorR to EyeColorB and able to send them the my Eye Class under the consturctor class Eye. the catch is I need to …

Member Avatar for Eragah
0
212

The End.