128 Topics

Member Avatar for
Member Avatar for nadiam

Hello. We're going into Constructora and super, using extends, subclasses etc. I have this code: class Student { private String name; private String matric_no; public Student(String n, String m) { name = n; matric_no = m; } } class UndergradStudent extends Student { private String programme; public UndergradStudent(String n, String …

Member Avatar for jacks009
0
231
Member Avatar for DS9596

Using an initialization list for a class array variable, what do you use to setup a slot with a 3parameter Ctor?

Member Avatar for rubberman
0
135
Member Avatar for Doogledude123
Member Avatar for can-mohan

Hi, As we know constructor doesn't have any return value so it is not good idea to perform exceptional handling inside constructor.SO i would like to know if i am opening a file inside constructor and due to some reason (file not exist) failure happened inside constructor then how to …

Member Avatar for can-mohan
0
381
Member Avatar for Tycellent

Hey everyone, Got 2 questions here that i'm hoping will be answered. Say i have 2 variables int iValue; int iValueArray[300]; and later on init. them in the constructor Banana::Banana(): ival(0), ivalArray() {} 1. What would the ivalArray() indicate? Would it be the same as initializing every element to null/empty? …

Member Avatar for Tycellent
0
323
Member Avatar for SkateX

Greetings, I'm working on a class project for fractions and I'm stuck and cannot figure out where to go from here. We have a mandatory driver file we aren't supposed to change. See below for example output and the output I am actually getting. **Sample Output** Enter numerator; then denominator. …

Member Avatar for Nutster
0
526
Member Avatar for NoobCoder85

Here is my code: ` #include <iostream> #include <iomanip> #include <string> using namespace std; class Register { //Private members private: //Creating an array for all the Prices static double Price[]; //Declaring RegNUM and RecNUM int RegNUM, RecNUM; //Print out Item name in a loop static string items[]; //Creates a Receipt …

Member Avatar for David W
0
366
Member Avatar for NoobCoder85

The tools Hal’s sells are: Hammers: $10.99 Wrenches: $10.99 Levels: $19.99 Tape Measures: $4.99 Screwdrivers: $8.99 In order to make things easier in the long run you have decided to make a c++ program that takes in all the orders for each register and tallies them at the end of …

Member Avatar for NoobCoder85
0
1K
Member Avatar for humorousone

Kind of stuck here. I'm porting over a section of code from Java to C#, and I'm having an issue with method permissions constructors. Early in my code, i have this class.. public class TCard { int suit; int rank; } and later i've got this method, which throws a …

Member Avatar for humorousone
0
24K
Member Avatar for nathan.pavlovsky

Hello programmers! I have been working on a hardware store application, where there is a `HardwareRecord`class that stores information about each object in a store (ex: nuts, bolts, screws, and so forth). Here's my declaration of this class: // HardwareRecord.h // Initialize Hardware Store File // // // Definition of …

Member Avatar for nathan.pavlovsky
0
19K
Member Avatar for Kristian_2

Hi guys, I have small problem with my example code. Any hint? #include <iostream> using namespace std; class A{ public: int a; A(int i){a = i;} A(const A& rhs) // copy constructor { a = 2; } A(const A&& rhs) // move constructor { a = 3; } }; void …

Member Avatar for mike_2000_17
0
409
Member Avatar for Brandon_6

You cannot determine whether a ctor is being called on an object that is to become const. Such as: const Foo bar( another_foo ); // no way to determine in the ctor that bar will be const I'd like some sort of function attribute for copy constructors to determine if …

0
156
Member Avatar for C

I had a programme to write for college in Java. I have missed the class so I won't be getting marked on it but wanted to get it done as I have an exam next we. I am really stuck. I have to create a costInsurance () method taking in …

Member Avatar for C
0
309
Member Avatar for Encheiridion

hi, done some work is not finished yet but this two versions\stages are runable. and what is very helpfull, to read opinion, suggestion, critic, ideas, feelings about. here is the link: http://softwareconstructor.webs.com/ and i need to read what u think about two firsts: * tryout2 (10bm) * and tryout1 (190mb) …

Member Avatar for Jorge Cordeiro
0
188
Member Avatar for Damian_2

Okay so inside my ArcherArmor.cpp, I'm trying to figure out why the map initializer list isn't working, but for some reason I keep getting "Error C2593: 'operator =' is ambiguous". Here is my code: I also have a class which ArcherArmor is derived from, that has a struct called `Armor`, …

Member Avatar for Damian_2
0
739
Member Avatar for Deegirl

Hello, is this how a constructor is created and initialized. I am getting an error; VB does not like the "New" what I am trying to do is to create a constructor with one argument and initialize its attribute. Public Sub New(ByVal newProdNumber As Long) intProdNumber = newProdNumber End Sub …

Member Avatar for chuchaykaw
0
213
Member Avatar for priyanka.choudhary.90038

Hi, I do have doubt regarding const declaration in copy constructor. Can anyone let me know why do we need const reference in copy constructor, as we already know reference itself is const pointer.So why we should use const as a prefix in copy constructor. Regards, Mohan

Member Avatar for deceptikon
0
1K
Member Avatar for Pyler

I'm trying to create a list stack that implements some interface called SomeList The list stack should only use stack with no links. the itnerface has a number of methods that I would like to implement. So for SomeList I have something like public interface SomeList<T>{public void plus(T something);public E …

Member Avatar for JamesCherrill
0
402
Member Avatar for can-mohan

Hi, Is there any way to not allow private construction in friend function, In case we do have private constructor with friend function in our class.Only Static method should be responsible for object creation and other than this compiler should flash error message. #include<iostream> #include<memory> using namespace std; class a …

Member Avatar for can-mohan
0
286
Member Avatar for Pyler

I'm having trouble pinpointing the exact definition of a generic linkedstack class Suppose I have public class LinkedStack<T> { //some variables //would this be right LinkedStack(){ } //for a generic constructor of type T for the LinkedStack class of type T? }

Member Avatar for JamesCherrill
0
129
Member Avatar for Himanshu Chawla

Ques : Define the class Book with all the basic attributes such as title, author, publisher, price etc. Define the default constructor, member functions display_data() for displaying the Book details. Use appropriate access control specifiers in this program I have done some part #include<iostream.h> #inlude<conio.h> using namespace std; class book …

Member Avatar for Himanshu Chawla
0
281
Member Avatar for Abo0od

class name { char *s; int len; public: name(){ // Default constr. s=NULL; len =0; } //************************************************** ~name(){ // Destruct. if (s!=NULL){ delete [] s; s=NULL; } } //************************************************* name(const char * s1); // Constr. char* getName(); //fcn get name int getLen() ; // fcn get lenght void setName(const char …

Member Avatar for Moschops
0
251
Member Avatar for dreking6

am a python beginner, receeently started learning about classesand i wrote this got this little code that keeps bringing this error . please i need someone here to help debug it: class employee(): ` empcount=0` def _init_(self,name,salary): self.name=name self.salary=salary employee.empcount=+1 def displaycount(self): print 'Total employee: %d' %employee.empcount def displayemployee(self): print …

Member Avatar for dreking6
0
6K
Member Avatar for mahesh113

Hi, Please tell me in the following question why no copy constructor is called when fun returns the A object. While returning b and constructing c, there is no copy constructor called. Why?? #include<iostream> using namespace std; class A { public: A(){cout <<"Default\n";} A(const A&){ cout<<"copy\n"; } A fun(A a) …

Member Avatar for mike_2000_17
0
336
Member Avatar for maalaakhantaurux
Member Avatar for vishalonne

Hi All I have a query regarding constructor and destructor. How accessibility of constructor and destructor affects the scope and the visibility of their class. If someone give some explaination on this I will be thankful. Regards

Member Avatar for David W
0
255
Member Avatar for vivosmith

Hey there, I am getting used to Java, but here is something that is stumping me: // Fig. 3.10: GradeBook.java // GradeBook class with a constructor to initialize the course name. public class GradeBook { private String courseName; // course name for this GradeBook // constructor initializes courseName with String …

Member Avatar for stultuske
0
236
Member Avatar for gabriel.riveraperossenkopp

I need to write a code with a constructor class in order to see the whole phonelist using an array that reads from a document txt, able to add a person and phone number, search just one person in the phonelist and able to modify their phone number. here is …

Member Avatar for elhkei
0
683
Member Avatar for xHellghostx

I am having a problem to understand how class inhertance works in Java.. Now I want to get information from a class to another and let's say we have class A and class B class A contains a string an int and a byte class B contains a String and …

Member Avatar for stultuske
0
280
Member Avatar for MRehanQadri

We cannot use constructors if we want that whenever a pointer is declared, it should be NULL. Am I right Sir? if I declare student *head, *tail, where student is a class, can I make my pointers automatically make NULL using default constructor?

Member Avatar for Moschops
0
165

The End.