Questions tagged [derived]

429 questions
3
votes
1 answer

Getting a pointer to a (pure) virtual function from a base class instance

I have the following c++11 code, which works, while I would have expected it to crash or even not to compile. Retrieving a pointer to a pure virtual member function should return a null or invalid pointer, or should be blocked by the compiler. I…
galinette
  • 8,896
  • 2
  • 36
  • 87
3
votes
1 answer

SQL count how many duplicated values of a derived table

I know this gets asked a lot but no other solution worked for me. I have this query: SELECT us.id AS idUser, ut.id AS idUtente, us.nome AS nomefunc FROM utentes ut JOIN historico h ON h.idUtente = ut.id JOIN users us ON…
xickoh
  • 304
  • 3
  • 10
3
votes
2 answers

How do you set a string data member from a base class, with a derived classed?

I have figured out most of the code/assignment, here is part of the "To-Do" I can't figure out: The derived classes set the m_type, but note, there is no setType function to do so (and you can't add one). Here is my code (nothing in main can be…
Hanna369
  • 61
  • 5
3
votes
4 answers

Template method over non-template method in derived class

class A { public: template void func(size_t n, T values[]) { ... } }; class B : public A { public: void func(size_t n, uint32_t values[]) { ... } }; Why does function B::func() not take precedence over the function template…
mnn
  • 1,952
  • 4
  • 28
  • 51
3
votes
5 answers

Calling base method from derived class

I have, for example, such class: class Base { public: void SomeFunc() { std::cout << "la-la-la\n"; } }; I derive new one from it: class Child : public Base { void SomeFunc() { // Call somehow code from base class std::cout <<…
Max Frai
  • 61,946
  • 78
  • 197
  • 306
3
votes
1 answer

Storing derived classes in a base class Dictionary

I am trying to create a scene or state manager which stores a Dictionary for each state as a way to load or change the state of the program (for example, a Main Menu state and a Game state). I have a bunch of derived classes of base class State…
Charsmud
  • 183
  • 1
  • 4
  • 19
3
votes
1 answer

c++ Derived Class of a class that represents items in a library

The LibraryItemsClass stores the Title and the Due date. The class has two constructors; A default constructor that gives the due date a value of 0/0/0 A constructor that accepts the title and gives the due date a value of 0/0/0 The Class has four…
3
votes
1 answer

access base class field from derived&&subclass

I can't understand why I have access to Base class's field. I have no object of Base class, and private fields are not inherited as I know. When I try to get field "i" of class "SubDerived" with reflection, it cannot find it. please anyone…
3
votes
2 answers

C++ storing base and derived class objects together

I Have two classes: First: class Thing { public: int code; string name; string description; int location; bool canCarry; Thing(int _code, string _name, string _desc, int _loc, bool _canCarry) { code = _code; …
Majak
  • 1,543
  • 1
  • 14
  • 28
3
votes
1 answer

Prevent a virtual function bering overloaded twice in a sub-sub-class

I have a base class Base, a somewhat more specialized class SpecializedBase derived from Base, and subclasses of the latter such as Derived. I implement a virtual function in SpecialisedBase which is pure virtual in Base. How to be sure that this…
galinette
  • 8,896
  • 2
  • 36
  • 87
3
votes
1 answer

How can I cast a subset of a dictionary to a type derived from Dictionary<>

To simplify using a specific type of dictionary I have derived a class from the generic Dictionary<> to handle assorted elements derived from a common base class: //my base class holding a value public abstract class A{ public int aValue;…
AstaDev
  • 149
  • 1
  • 8
3
votes
1 answer

Java - overridden method not getting called

I'm working on a Java exercise and can't figure out what I am doing wrong. I made a Movie class (with variables: rating, title, movieId and a constant for FEE_AMT) and then extended the class with: Action, Comedy and Drama. These derived classes…
Kirk B
  • 551
  • 6
  • 23
3
votes
2 answers

Converting a string to a decimal value in an SSIS package

I have a flat file that I am importing into SQL Server 2008 using an SSIS package. The file contains a field with a number, followed by a column with a negative sign when the preceding column value is negative. For instance: Price Sign ----- …
user1949225
  • 33
  • 1
  • 1
  • 3
3
votes
1 answer

How to make a deep copy of an object which is derived from a List

I have the following classes: public partial class AuthorizationSetObject { public AuthorizationObjectList AuthorizationObjects { get; set; } } public partial class AuthorizationObject { public string Text { get; set; } } public partial…
Marc
  • 137
  • 3
  • 10
3
votes
5 answers

Is there any way to know if the non-pure virtual function has been implemented by the derived class in C++?

I am creating a class which is callback based. I need to give the client a freedom to invoke the callback that he defines. For example, I have a class Base: class Base { ... public: virtual void OnMsgReceived(const char *msg, char *&response); …
Leonid
  • 31
  • 1