135 Topics

Member Avatar for
Member Avatar for can-mohan

Hi All, i am curious to know how to set the value (value=10) through B's constructor in below programme. below is example of multiple inheritance. As construction always happens from right to left so it always call the 'C' class's constructor and set the value 20 but as per my …

Member Avatar for can-mohan
0
470
Member Avatar for Usman_10

inheritance error is::Error 1 Inconsistent accessibility: base class 'person' is less accessible than class 'employee' using System; using System.Collections.Generic; using System.Linq; using System.Text; //person class public class person { public string name; public double CNIC_no; public void Information() { Console.WriteLine("Enter your name"); name = Console.ReadLine(); Console.WriteLine("Enter your id"); CNIC_no =double.Parse( …

Member Avatar for pritaeas
0
246
Member Avatar for ddanbe

Inheritance with generic types can sometimes be tricky. If you would inherit from a Stack<double>, no problem, but what if you want to keep it as generic as possible? Maybe it's a bad idea, but I wrote something like `class Stacker<T> : Stack<T>` and in Stacker I implemented some arithmetic …

Member Avatar for JOSheaIV
1
768
Member Avatar for gahhon

I have a Task class (superclass) which inherited PracticeTest class(childclass). I'd faced question regarding my pass year question. In fact, we are allowed to declared like this Task aTask = new PracticeTest(); But i wonder why we are doing this way? Thanks for advance explanation.

Member Avatar for JamesCherrill
0
204
Member Avatar for ddanbe

Is it possible to let an overridden method from a base class to return the type of the derived class? What I mean is: namespace test //with some "pseudo" code { class Base<T> { //fields ... //properties ... // ... public virtual Base<T> BaseMethod() { //return new Base<T>; } // …

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

Hi guys, I would like to discuss my design with one query. below is the code snippet. It is clear from below code snippet that class pd is privately derived from AbstractClass as both are different classes and there is no relation between them.Now in my class pd i need …

Member Avatar for can-mohan
0
407
Member Avatar for VengefulToast

Hi fellow members, I have wrote two abstract classes, with the second inheriting from the first. However, I receive this error when I try to compile: "error C2143: syntax error : missing ',' before '<'." Will somebody help me out? Thanks! template <class DataType> class AbstactArrayClass { friend ostream& operator …

Member Avatar for mike_2000_17
0
275
Member Avatar for PulsarScript

//Hi all just switching from c++ to c#.Can anyone help,with the question i have: //this is a peace of code from c++ banking aplication int ShowMenu(void); void AddAccount(vector<CAccount*>& list); void DisplayAccount (vector<CAccount*>& list); void Lodgement (vector<CAccount*>& list); void Withdroawal (vector<CAccount*>& list); void InterestRate (vector<CAccount*>& list); CAccount* findAccount (vector<CAccount*>string ); bool …

Member Avatar for ddanbe
0
2K
Member Avatar for redtribal23

Why this doesn't work? class Faculty extends Employee { private long[] officeHours; private String rank; public Faculty(long[] hours, String rank) { this.officeHours = hours; this.rank = rank; } public static void main(String[] args){ //some code here Faculty f = new Faculty(newToken[], tokens[tokens.length-1]);

Member Avatar for vivekH
0
252
Member Avatar for Maritimo

One of my students make me a question (which answer i know) but I think could be instructive to formulate the same question here so many people can learn about it. The question is: How to implement a copy assignment into a Derived class? Consider the following class A: class …

Member Avatar for pritaeas
0
380
Member Avatar for Tycellent

Hey everybody, As of this moment i'm trying to work out how to approach a state design. I've come across Source Makers' site [http://sourcemaking.com/design_patterns/state/cpp/1](http://sourcemaking.com/design_patterns/state/cpp/1) and am testing out the example. The program works fine when it's all in 1 file, although i had to change some stuff in main, but …

Member Avatar for rubberman
0
3K
Member Avatar for aanchal_1

this program is simply for recording data of various staffs.Inheritance has been used for taking additional data.Staff is the base class.the classes officer,typist and teacher are the derived classes.again the classes regular and casual are derived from the class typist. **now my problem is that whenever i call the constructor …

Member Avatar for aanchal_1
0
276
Member Avatar for theashman88

I'm trying to create a program that passes arguments of size of three shapes, a circle, a triangle, and a rectangle. I got those but everytime I run the code it displays the arguments as 0 instead of giving me the shape dimension. Here is the code. using System; class …

Member Avatar for kvprajapati
0
281
Member Avatar for Pyler

I have two classes A Dog class whose constructor does not accept arguments, `public class Dog<pet> extends Animal<pet>{}` whose constructor does not accept any arguments and `public class Animal<pet>{}` whose constructor accepts one argument public class Dog<pet> extends Animal<pet>{ public Dog(){ super(/*what should go here?*/); //Constructor accepts no arguments } …

Member Avatar for stultuske
0
236
Member Avatar for samson.dadson.3

please i have a little problem creating a class and making it run. The class is created separately as a header file with it's source code. whenever i build the source code of the class, i get an error that says: undefined reference to 'WinMain@16'. And whenever I run the …

Member Avatar for samson.dadson.3
0
415
Member Avatar for asadmoosvi

I have been programming for quite a while in Python but have just started to learn OOP properly. I find it really confusing and I don't really understand it. Especially the implicit self that python automatically passes. It just isn't clicking, really. May someone provide an easy explanation of what …

Member Avatar for vegaseat
0
319
Member Avatar for tyler.dahle

package hw3.categories; import java.util.ArrayList; import hw3.DiceGroup; import hw3.api.IScoreCategory; /** * Scoring category for a yahtzee. A DiceGroup * with N dice satisfies this category only if all N * values are the same. For a dice group that satisfies * this category, the score is a fixed value specified in …

Member Avatar for JamesCherrill
0
222
Member Avatar for Gaetane

This started out as `I love PHP traits! I'm going to use them everywhere! ^_^` and now it has turned into a `Thought Exercise / Learning Experience >_<`. Consider the following example: trait TheErrorOfYourWays{ public function booboo(){ echo 'You had a booboo :('; } } trait SpectacularStuff1 { use TheErrorOfYourWays; …

Member Avatar for Gaetane
2
2K
Member Avatar for Labdabeta

Hello, I am working on an event driven library and am having one minor problem. Basically I have two ways to get what I want done. Method 1: Smart pointers and factory functions #include <iostream> #include <vector> #include <memory> using namespace std; class Object { public: virtual int getInt(){return 0;} …

Member Avatar for Labdabeta
0
254
Member Avatar for skyyadav

#ifndef BASE_H #define BASE_H class Base { public: int m_nValue; Base(int nValue=0) : m_nValue(nValue) { std::cout << "Base" << std::endl; } }; #endif #ifndef DERIVED_H #define DERIVED_H #include "Base.h" class Derived: public Base { public: double m_dValue; Derived(double dValue=0.0) : m_dValue(dValue) { std::cout << "derived se" << std::endl; } friend …

Member Avatar for gerard4143
0
313
Member Avatar for Labdabeta

Hello, I am having a particularly nasty case of "What is the syntax?" while working on an event driven library. Basically this is what I want: class Object {// private: public: virtual bool onEvent(Event e)=0;//all objects have to react to events Object operator|(const Object &o) { // I want to …

Member Avatar for Labdabeta
0
305
Member Avatar for kruschev

#include <string> #include <iostream> #include <vector> using namespace std; class Person { public: Person(); Person(string n, string a, string tel, string em); string getName(); string getAddress(); string getTel(); string getEmail(); virtual string whatAmI(); private: string name, address, telephone, email; }; Person::Person() { } Person::Person(string n, string a, string tel, string …

Member Avatar for Krimeplay
0
356
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 Jugottabe

Hey guys, slightly less noob programmer here for a some more help, This week in class we were assigned to create a phonebook with a couple functions to manipulate it, but it seems I am having a couple problems. It seems to me that I have most of the program …

Member Avatar for DeanMSands3
0
223
Member Avatar for Stpdoug

Hey guys i am having trouble with creating a Parent class(gameobject) for two other child classes(player,location) both of the child classes can access data from the parent class, and work well independently but once i include the h file for the child classes together in main.cpp i get the compiler …

Member Avatar for UFOOOOOOOOOOO
0
349
Member Avatar for abhimanipal

Hi Guys, I am trying to teach myself templates and I keep getting lost in all these compilation errors. Here is the latest // This is the interface for the base class template<class V, class I =int> class Array{ private: vector<V> myStore; public: Array(); Array(I size); Array(I size, V value); …

Member Avatar for abhimanipal
0
242
Member Avatar for Jugottabe

Hey guys, noob programmer here. Over the last week or so we've been learning about classes and inheritance in my latest progamming class. I've recieved a variation of the ever so popular poker program and am having some problems putting it all together. I haven't had the opportunity to test …

Member Avatar for Jugottabe
0
377
Member Avatar for tanatos.daniel

I have the following structure: CObject { protected: char *mName; public: CObject(char *n) { mName=strdup(n); } }; CVector:public CObject { char *mValues[50]; int mElements; public: CVector(char *n):CObject(n) {} }; CMatrix:public CObject { char *mValues[50][50]; int mLines; int mColumns; public: CMatrix(char *n):CObject(n) {} }; My main function: int main() { pV=new …

Member Avatar for deceptikon
0
380
Member Avatar for Labdabeta

Hello, I have a chain of inherited classes like this: class A { protected: int a; public: int getA(){return a;} }; class B:public A { protected: int b; public: int getB(){return b;} }; Based on that you can see that the public can only read the values in those classes, …

Member Avatar for Labdabeta
0
249
Member Avatar for james.lu.75491856

Traceback (most recent call last): File "C:/Users/James/Desktop/hugevar.py", line 2, in <module> class var(tempfile.TemporaryFile): TypeError: Error when calling the metaclass bases function() argument 1 must be code, not str Why does this happen and how can I fix it?

Member Avatar for Gribouillis
0
989

The End.