Questions tagged [subclass]

A subclass is a class that derives or inherits from a parent (or super) class. Subclassing is used extensively in object-oriented programming (OOP).

A subclass is any class that inherits from a parent (or super/base) class. Depending on the language, a subclass will have a subset of the attributes and methods of the (parent/base) class from which it inherits. As a result, it is important to always tag a question with the language being used when tagging it with this tag

4137 questions
1
vote
0 answers

C++ how to overload += in subclass and superclass

class Rectangle : public Shape { protected: int width; int length; public: Rectangle(const int pwidth, const int plength, const int px, const int py); Rectangle& operator+=(Rectangle& rhs){ this->width += rhs.width; …
JJaco
  • 61
  • 1
  • 11
1
vote
0 answers

I have a UIButton subclass that I have set an image to in IB, and strangely about 1/3 of the button won't respond to touch! What's going on?

As described, I have a UIButton subclass, that I am designing in IB. I have set the button subclass to a UIView, and set an image to the button as well. I have set a UILabel beneath the image, attempting to give it the Finder look. Everything works…
Steven S.
  • 45
  • 1
  • 5
1
vote
1 answer

How to separate view from viewcontroller using storyboard swift?

Practicing MVC pattern and want to separate view from viewcontroller using storyboard. in main.storyboard I have a viewcontroller, and there are some uilabels in rootview. to separate view code from viewcontroller, I selected view from…
alphonse
  • 687
  • 1
  • 6
  • 16
1
vote
1 answer

missing argument for parameter in coding error in trying to subclass a uibezierPath

I want my swift code to display a uibezierPath button. The code uses override func draw to draw the button. The code is getting a compile error. Its telling me I am missing a parameter in let customButton = FunkyButton(coder: <#NSCoder#>) you can…
joe buck
  • 31
  • 1
  • 7
1
vote
1 answer

UnitTest in Python

Possible Duplicate: ValueError: no such test method in : runTest import unittest class BzTestSe(unittest.TestCase): DEFAULTUSERNAME = 'username-a2' DEFAULTPASSWORD = 'pass' DEFAULTHOST =…
Somu
  • 113
  • 1
  • 7
1
vote
1 answer

How can I avoid having two classes with the same properties

I am coding in C# in Unity3D. This is my first question on Stack Overflow. I hope to be in order. In my game I have two empty sub-classes that work as kind of an enum extension and that are exactly the same: public class Condition { public int…
1
vote
1 answer

using static class methods in another class in typescript

I want to use certain static methods from another class in my code, but getting a weird error. class Mouth { static greet() { console.log('Mouth.greet') } } class DogMouth extends Mouth { static greet() { console.log('DogMouth.woof') …
dcsan
  • 11,333
  • 15
  • 77
  • 118
1
vote
1 answer

Difference in creation between Inner and Subclass

I noticed that to make Inner class we need instance of Outer class. But to also make a Subclass, we need Parent class to create instance, as well. What is difference between them if there is some? Strictly speaking in creation and not how they work.…
Stefan
  • 969
  • 6
  • 9
1
vote
0 answers

Python 3 Linearization rules

I can not find out the rules followed by python to make the linearization of the following class hierarchy: class Type(type): def __repr__(cls): return cls.__name__ class O(object, metaclass=Type): pass class F(O):pass class…
JorSan
  • 65
  • 9
1
vote
2 answers

NSButtonCell subclass' button type not working

I subclassed the NSButtonCell class to give a different look to my button. I have the drawing code working fine. It's a rounded button filled with CGGradients to look like the iTunes playback controls. They are not completely the same, but they…
v1Axvw
  • 3,054
  • 3
  • 26
  • 40
1
vote
8 answers

Something weird is happening to the Person

In the following java code public class Person { int age = 18; } class Student extends Person { public Student() { this.age = 22; } public static void main(String[] args) { Student student = new Student(); …
Abu Muhammad
  • 1,185
  • 5
  • 20
  • 29
1
vote
2 answers

Subclass type as function parameter

I have an array of objects. The array contains different subclasses. class MainClass { } class SubClass1: MainClass{ } class SubClass2: MainClass{ } var arrayOfObjects = [SubClass1(), SubClass2(), SubClass1()] I want to include a function that…
Flocked
  • 1,898
  • 2
  • 36
  • 57
1
vote
1 answer

Qt - subclassing to provide an alternative view for a text widget?

Currently, I am in the design phase of a Qt widget like what one would see in a typical hex editor. It seemed simple enough to begin with, but as I dig into its implementation details I’m having some confusion. Basically, the widget would consist of…
Zac
  • 876
  • 1
  • 8
  • 18
1
vote
2 answers

Abstract Class in std::unique_ptr as a Return from Function not Working

class Base{ public: virtual std::string typeName() = 0; virtual ~Base() = 0; }; Base::~Base(){} class D1 : public Base{ public: std::string typeName(); std::vector> children; ~D1(){}; }; class D2 : public…
1
vote
1 answer

I am having issues with the amount when I run the command with while loop in python

I imported a json file and created a while loop for rice bank account for super rice. I create def under parent code but encountered an error: TypeError: withdraw_money() missing 1 required positional argument: 'amount'. I am also trying to put new…
maria
  • 13
  • 2