Menu
  • HOME
  • TAGS

Cant declare a QWidget because virtual functions are pure

c++,qt,function,virtual,abstract

class Widget : public QWidget, public ADTType So Widget inherits from the abstract class ADTType. However, you don't declare the overrides (startGame() etc) in your Widget class, but you only define them in the Widget.cpp file. You also need to declare them in the Widget.h class header // need these...

RTSP stream to virtual video device on Windows 8

video,driver,virtual,directshow,rtsp

Actually VMIX video mixing software will pull from just about any stream, diretx compatible video capture card (including the easy cap 9$ capture card on ebay) and then output to a directshow compatible virtual device, AND it can do it to two virtual devices at the same time.. AND the...

Saving Files in to the memory/virtual file C#

c#,memory,save,virtual

If your component want to recevice a file, you need a file on your HDD/SSD. In those cases, i prefer to use the APP-Data folder and create a sub directory in it. It is accessable over: Environment.SpecialFolder.LocalApplicationData. To come back to your question, it is not possible. Because the method...

C++ base class function call from last derived in diamond design

c++,inheritance,virtual,diamond-problem

Your question seems to not be related to the diamond pattern, but is generally about the inheritance model in C++. Most things in C++ are statically bound, so at compile time the compiler fixes what method or member of a certain name is used: If you access a member of...

Why calling pure virtual function imlemented in child inside constructor doesn't work?

c++,inheritance,virtual

When you are in the base class constructor, the details of the derived class has not been filled in yet -- which means the virtual function table is not completely filled in yet. The virtual function table does not point to any of the derived class functions. If you call...

Virtual function taking parameters of base class type

c++,virtual

dosomething() accepts a reference to the A portion of an object. A does not have a member named y, just like the compiler error says. Only B has a y member. Imagine there is another class C that also derived from A but not B, where C does not have...

using biginteger for java program regarding virtual addresses

java,virtual,biginteger

BigInteger address = new BigInteger(address); if(page >= 512 && page <= 16384){ if(address.compareTo(new BigInteger("0"))>=0 && address.compareTo(max)<=0){ } } ...

Jquery based Arabic Keyboard

php,keyboard,virtual,arabic

Try this: http://www.arabic-keyboard.org/keyboard/ Here is the snippet to add: <input type="text" id="YourId" value="" dir="rtl" class="keyboardInput"> <link rel="stylesheet" type="text/css" href="http://www.arabic-keyboard.org/keyboard/keyboard.css"> <script type="text/javascript" src="http://www.arabic-keyboard.org/keyboard/keyboard.js" charset="UTF-8"></script> You can download keyboard.js, keyboard.css and keyboard.png, and upload them to your server to be independent....

GCC's nm lists multiple entries for method

c++,gcc,virtual,nm

In some cases the demangler will demangle different inputs to the same output. This can be mildly confusing at times but is done, I think, because in other cases it is less confusing; for example the demangler is used by gdb and this approach lets breakpoints on constructors do the...

Abstract class as a type, derived class as instance in C++

c++,inheritance,tree,iterator,virtual

Remember, in Java, you don't deal directly with objects, you have pointers to objects. In C++, when you declare a variable of type x, you have an x, not something that derives from x. If you want to use polymorphism, you need either a reference (x&) or a pointer (x*,...

Slice off overridden method by casting

c++,casting,virtual,base,derived-class

Since private method can't be called qualified and the override can't be undo you won't be able to call the private method without another object. Casting the object won't have any effect because the way virtual functions are handled is part of the actual object. In the past I had...

Would this simple code cause a memory leak?

c++,inheritance,memory-leaks,virtual,destructor

You are delete-ing a derived through a pointer of type base*, and base does not have a virtual destructor. That is Undefined Behavior (UB), which means anything may happen. While causing a memory-leak if the std::string has allocated any memory (think short-string-optimization, which would mean no extra memory needs to...

Magento: virtual products not showing

magento,virtual,product

Make sure if all products are active and there is no condition which cause hiding them. (especially EAV attributes Visibility in Catalog and Search, Status is set to Active, Have items or store, or have disabled selling only store items), reindex, clean cashes!

C++ unsafe cast workaround

c++,virtual

You have to consider how the class is laid out in memory. TBase is easy, it's just four bytes with one member: _ _ _ _ |_|_|_|_| ^ m_iData TStaticDerived is the same. However, TVirtualDerived is totally different. It now has an alignment of 8 and has to start up...

Providing a definition for a pure-virtual function

c++,virtual

You are allowed to define any pure virtual member function. However, even though you define A::foo, it is still pure, so A and B are still abstract classes and may not be instantiated. That will be the cause of any errors your compiler may emit.

force cakephp 3 auth->user() to show virtual fields

cakephp,authentication,field,virtual,cakephp-3.0

Update The problem has been fixed in the core, the authentication adapter now fetches entities and converts them via toArray(), so that possible virtual fields are being included, given that they are defined in the $_virtual property as noted below. The problem here is the authentication adapter, it fetches the...

C++ Inheritance pure virtual functions

c++,function,inheritance,virtual

Lets' put those two side by side and look closer: A: virtual std::pair<A*, A*> f1(const A& o) const=0; B: virtual std::pair<A*, A*> f1(const A& o); Well, I see a difference, one of these is a const function, and the other is not. That makes them two different functions. Since the...

Why std::unary_function doesn't contain virtual destructor

c++,virtual,destructor

In a well-balanced C++ design philosophy the idea of "preventing" something from happening is mostly applicable when there's a good chance of accidental and not-easily-detectable misuse. And even in that case the preventive measures are only applicable when they don't impose any significant penalties. The purpose of such classes as...

Virtual base class initialization conundrum

c++,visual-c++,virtual

This issue is fixed in clang 3.4, but not earlier. Given that it is a compiler bug or at least a contentious compiler trait, and that Base(Connection& conn) is protected, you might be able to go with an in-your-face conditional compilation workaround, e.g. class Base { protected: #if HAVE_BUG_GCC19249 Base(Connection&...

polymorphism, virtual methods, C++

c++,polymorphism,virtual,member

C++ polymorphism works only for pointers and references. liste[0] has type A, not A* or A&, so the liste[0].getV() call is not dispatched virtually. It just calls A::getV().

Template class override base class virtual function

c++,templates,c++11,override,virtual

Base GetSpecialization(const int&){ return IntSpecialization(); } You're slicing the IntSpecialization object above. To make your code work, GetSpecialization must return a Base *, or a Base&. For instance, the following will work as you intended it to: std::unique_ptr<Base> GetSpecialization(const int&) { return std::unique_ptr<Base>(new IntSpecialization()); } Live demo For the above...

C++: Do virtual function calls with a pointer to the derived class still have a vlookup

c++,templates,inheritance,virtual

Disclaimer: Compiler Optimization This answer is about compiler optimization techniques. Your compiler may or may not support these. Even if it supports the technique you are trying to exploit, they may not be available at your chosen optimization level. Your mileage may vary. Most Derived Class The compiler can indeed...

Warning: direct base class inaccessible in derived due to ambiguity; is this serious?

c++,inheritance,virtual,ambiguity

template <typename T> class ScrollSpell : public T, public SpellFromScroll {}; Here, T = Spell, so the ScrollSpell class has the Spell class as a direct, non-virtual base class, and also as a virtual base class through SpellFromScroll. That is the ambiguity. Declaring the base class T as virtual might...

Is C++ virtual definition inherited automatically?

c++,polymorphism,virtual

If you inherit from Bar you should have class Bar:public Foo { public: virtual void a() override { //... } }; So you are saying two things about a() here: The function is virtual so anything that derives from Bar will treat the function as virtual You are overriding the...

Virtual function performance when called by derived classes?

c++,performance,function,virtual,derived-class

Is there a performance penalty when a virtual method is called from a class that's known to be the derived class at compile time? See code below. It depends. Most compilers will "de-virtualize" code like this: Derived1 d; d.speak(); The dynamic type of the object is known at the...

Memory usage by virtual inheritance

c++,inheritance,memory-management,virtual,multiple-inheritance

It depends on the implementation, but typically virtual inheritance will need: an extra pointer (or offset) for each virtual base class: the adjustment to convert (for example) B* to A* will depend on which other subobjects in the same object also derive virtually from A. I think this can be...

What() method for std::exception isn't acting virtual?

c++,exception,c++11,virtual

Change this statement: catch(exception a) {cout << a.what() << endl;} to this: catch(const exception &a) {cout << a.what() << endl;} You have to catch an exception by reference in order for it to use polymorphism. Otherwise, you are slicing the std::runtime_error object so only a std::exception object remains, thus std::exception::what()...

Drush with several Virtual Hosts on Apache web server

apache,drupal,virtual,drush

You might want to use the option --rootto specify the webroot of your drupal installation. You can also specify the website URL using the option --uri, if you have a multisite installation. Look at http://docs.drush.org/en/master/usage/#options for an in-depth description. But the best way to handle you setup is drush aliases...

Derived classes' functions not being called

c++,inheritance,virtual,derived-class,base-class

The problem is that that you're trying to make C++ do multiple dispatch for you, which it doesn't do, quite simply. Methods with the same name but different argument types are, for all intents and purposes, completely different methods, and as such do not override each other. Since your q...

Understanding output when virtual functions are called directly using vptr

c++,inheritance,virtual,vtable,vptr

The whole idea of object oriented programming is to follow abstraction. When you have virtual function, meant for dynamic binding, use it through the abstraction by calling the virtual function for the base class pointer. Depending on where it is pointing dynamically in the class hierarchy, it will dynamically bind....

multiple inheritance casting between parents __vftable seems corrupted

c++,inheritance,virtual,multiple-inheritance

Multiple inheritance is something really great and powerful. However, it requires extreme care when using casting. And unfortunately, what you do is undefined behaviour. What is going wrong here ? First you create a CUser by passing to the constructor a CItem pointer. As the constructor is only defined for...

C++ - Getting and setting member variable within same method?

c++,virtual,setter,getter

To answer your question, separate getters and setters are at the core of encapsulation. While it may save you an extra function call, it's much cleaner and safer to have separate functions for getting and setting. Here's some tweaked code to understand better class Derived : public Base { public:...

Trouble with dynamic array of pure base class c++

c++,arrays,dynamic,polymorphism,virtual

You're displaying starting from 0: for(int i=0; i<cnt2; i++) { sPtr[i]->display(); } But you're adding to sPtr starting at 1: int cnt=0; while(cnt<20) { cnt++; ... sPtr[cnt] = new ...; } These kinds of errors are a great reason to prefer to use std::vector<Shape*> to raw arrays and counters. Then...

Polymorphism in C#. Base Class's Method is Called But Why? [duplicate]

c#,inheritance,polymorphism,override,virtual

You create an instance of B that is lets say "Bigger", but the variable 'a' is converted into class A that is "Smaller" and contains the method print A. You did something similar to: A : IClass B : IClass The interface exposes some method that is in both A...

Virtual Function During Construction Workaround

c++,constructor,virtual

This is the factory method approach, putting the factory into the base class: class A { public: virtual void read() = 0; template<class X> static X* create() {X* r = new X;X->read();return X;} virtual A* clone() const = 0; }; class B : public A { B():A() { }; friend...

C# virtual mouse click in Flash apps

c#,flash,mouse,virtual,handle

I found it... You should Run your process as Administrator to do that......

How to change application root in a virtual url

java,tomcat,spring-security,virtual,spring-roo

The short answer is that you can't (easily) without some help from your IT Admin. You need to know how they are reverse proxying the public URL to your Tomcat instance and then you are almost certainly going to need to ask them to make some changes. What those changes...

What happens when an asynchronous callback calls a virtual function, while base class constructor is not returned yet?

c++,constructor,callback,virtual,asynccallback

According to the C++ Lite FAQ 23.5, Base::virt() will be called. Anyway, it's really not something you want to do - if your object is used by another thread without proper initialization, you can encounter all sorts of nasty race conditions. For example, what would happen if the second thread...

2D Array of objects with virtual child methods -> “vtable referenced from” error

c++,arrays,xcode,runtime-error,virtual

You said that your base class is Tile, and has the following pure virtual method virtual void setVals(int ID) = 0; But yet you went on to define it? void Tile::setVals(int ID){ switch(ID){ case 1 : GFX_ = '?'; name_ = "Nothing"; desc_ = "You shouldn't be seeing this"; break;...

virtual class and polymorphism

c++,class,object,polymorphism,virtual

You could just pass the base class Shape to the add function. Just pass a pointer to the object to store it inside your vector vector<Shape*> v; bool add(Shape *shape) { uint i = 0; for( i = 0; i < v.size(); i++ ) { if(shape.isequal(*v[i]) == true) return false;...

Derived class that inherits virtual class c++

c++,inheritance,virtual,derived-class

This code class motorcycle: public motorVehicle, public twoWheels, virtual vehicle{//(1) .... }; inherits your class from both motorVehicle and twoWheels, which both already inherit vehicle. Thus you have to disambiguate the construction of vehicle, and adding virtual vehicle to the inheritance hierarchy, does so by choosing the first available constructors...

C++ - virtual operator= being called on Base class from Derived instance? [duplicate]

c++,polymorphism,operator-overloading,virtual

What you're forgetting is that regardless of what you have written, you still get a derived-specific copy assignment operator provided by the compiler. Since it's a better match than the base-class version, the default one is called.

VirtualBox VM won't boot

vagrant,virtualbox,virtual

I managed to fix it by just shutting down the Virtual Box VM network.It set itself up again on NAT when I rebooted the VM, so that was the solution... It's probably a virtualbox bug.

Strange behaviour when calling virtual functions

c++,virtual

This is due to name hiding. When you declare a function called foo in Bar, you hide all declarations with the same name in Foo. As such, when the static type of the pointer is Bar, the compiler only finds the version in Bar which takes a double, so it...

virtual function calls and casting

c++,virtual

Virtual functions work through the object itself. Inside the A or B structures, there is some information (typically called a vtable) which contains the pointers to the virtual function(s), in this case, foo. This is kind of the point, that you WANT to call the function that belongs to some...

About an exception's virtual function in C++

c++,virtual,throw

You should always catch by reference. Const reference wouldn't be a bad idea either, since you normally don't need to modify an exception: catch(const Exception& e) Otherwise you are "slicing" the exception, which is a common mistake. Not to mention that copying an exception while it is in flight is...

Why do virtual field-like events work the way they do in C#? [duplicate]

c#,events,virtual

Field-like events are expanded by the compiler to something like this: public abstract class MyClassBase { private EventHandler _myEvent; public virtual event EventHandler MyEvent { add { _myEvent += value; } remove { _myEvent -= value; } } public void DoStuff() { if (_myEvent != null) { _myEvent(this, EventArgs.Empty); }...

can we access static member variable of pure virtual class?

c++,static,virtual

You have to define static member static int sVar; independently of the class in implementation file. int cTest::sVar = 0; //initialization is optional if it's 0. As far as your questions concerned :- Q1) static member variables are created when the 1st instance of the class is created. No static...

C++ access violation when calling virtual method [closed]

c++,virtual,access-violation

Found the answer myself. Accidentally deleted the guiElement.

Issues with calling child method in parent's class in C++

c++,constructor,virtual

During execution of the base class constructor, the object does not know that it will eventually become an object of a derived class. That's why the function in the base class is called instead of the one in the derived class.

Difference sizeof in C++ Classes with virtual parameter

c++,class,virtual,sizeof

This happens because classes that have virtual functions are usually implemented by the compiler via a virtual table, see also this explanation. And to use such virtual table, they store internally a pointer to the table. In your case, the size of CoolClass is given by the size of the...

Initialisation of objects with/without vtable

c++,constructor,virtual,variable-assignment,vtable

Your non-virtual functions "work" (a relative term) because they need no vtable lookup. Under the hood is implementation-dependent, but consider what is needed to execute a non-virtual member. You need a function pointer, and a this. The latter is obvious, but where does the fn-ptr come from? its just a...

Virtual Inheritance Issues

c++,inheritance,virtual

Ok, I've found one working solution, with the added information that Thing is abstract (thus making the solution harder and the above solution invalid): #include <iostream> #include <string> struct Thing { struct PartialData { int width, length, height, mass; }; //**Added struct PartialDataTag {}; //**Added std::string name; int width, length,...

C# call abstract method from static method

c#,static,virtual,abstract

I did it! lol, i implemented abstract static method in C# ! what did i: created abstract class AbstractDbParameterConstructors, that don't contains any state, only abstract methods. class ASqlWorker now gets generic, inhereted from AbstractDbParameterConstructors. public abstract partial class ASqlWorker<TPC> where TPC : AbstractDbParameterConstructors, new() { ... } declared private...

Template specialization implementation in cpp file causes template-id does not match error

c++,templates,constructor,virtual

There are couple of problems. One was pointed out by @dyp in the comments section to your question. You need to use: void Foo< ValA >::doSomething() { } instead of template<> void Foo< ValA >::doSomething() { } The other one is that you have to change the class template to:...

Template return type of a function that needs to be virtual

c++,templates,virtual

... T* fooHelper() {return new T;} }; template <typename T> T* create (A* a) { return a->foo(T{}); } The instance of A has no effect on the T you return. I'm assuming maybe that's supposed to be an argument. It also seems like you want a factory. How about using...

How to implement pure virtual functions with different parameter structures

c++,polymorphism,virtual,abstract,pure-virtual

For writing query functions (ie. same interface for all databases), pure virtual functions are the way to go. Here, you are trying to write an open function, for which you might want to consider the Factory Design Pattern: you write your Database withour any open function; and you write a...

Intel Virtualization Technology, HAXM cannot be installed

android,windows,virtual,virtualization

You can try these steps: Open Control Panel Open Programs and Features. Click on Turn Windows features on and off. Uncheck Hyper-V option and restart your computer. After that you should be able to install HAXM...

c++ objected oriented programming exception failure

c++,oop,exception,inheritance,virtual

Add the prototype destructor to your derived class from Auto_Rent_Exception. virtual ~Auto_Rent_Exception() throw(); On a side note you should be careful about using std::string (or anything that allocates memory dynamically) in an exception class. In case some API function fails (e.g. because there is too little memory left), chances are...

MSVAD Virtual Audio Sample Driver “Inf2Cat Signability test failed” (Windows WDK 8.1)

audio,driver,windows-8.1,virtual,inf

Solved. I found a tutorial that helped solve the problem. Just a step-by-step on what to do. See: https://technet.microsoft.com/en-us/library/dd919238(v=ws.10).aspx...

C++ passing base type to pure virtual function

c++,abstract-class,virtual

I think there are two ways to handle that problem. Let's start with some really bad solution: using casting. In that case dynamic_cast. You can try to down cast a type. If dynamic_cast isn't able to do that it is going to return a null pointer or throw and exception...

virtual function hirarchy in c++

c++,virtual

A::f and B::f are two different functions, even though they have the same name; since B::f was not declared as virtual only A::f is virtual - and nobody overrides it. pb->f() uses the static type of the pointer, which is B*, to determine which function to call; that would be...

DataGridView Loading Images OutOfMemory Exception

c#,datagridview,datatable,out-of-memory,virtual

Try to private void ClearNotVisibleImages() { foreach(var row in this.GetNotVisibleDataRowsWithImages()) { var cell = row["Image"]; Image image = (Image)(cell .Content); cell.Content = null; image.Dispose(); } // If it will be really needed GC.Collect(); // Improved Thanks @rentanadviser GC.WaitForPendingFinalizers(); GC.Collect(); } ...

C++ virtual assignment operator

c++,virtual,assignment-operator

Your problem might be that you define the class in a namespace, but you define the operators outside that namespace without specifying it. Because of this, the compiler can't connect the definition to the declaration. Ishamael pointed out that you don't specify what happens when a non-Point Shape is assigned...

Pointer casting leads to crash in c++

c++,pointers,casting,crash,virtual

Derived* d; That's a pointer, but you don't initialise it to point to a Derived object, so it has an invalid value. Using it gives undefined behaviour; most likely, a crash due to accessing an invalid address. Try creating an object, then using a pointer to that: Derived d; Base...

C++ inheritance and virtual funcions

c++,function,class,inheritance,virtual

1.Constructor design How will you set their gravity center ? Point center_of_grav(a,b); ... Square square(c); // what's the gravity center ? You have to design the constructor of the derived, so that it has all information required to construct the base: Square square(center_of_grav, c); To achieve this, you have to...

Does it make any difference if a virtual method is declared virtual in the subclass? [duplicate]

c++,override,virtual

There is no requirement to mark an overriden virtual method virtual in a derived class. The decision whether a method is virtual or not is made in the least derived class. It is, however, a good idea to mark a virtual method explicitly virtual in a derived class for two...

C++ inheritance and abstract function implementation

c++,inheritance,polymorphism,virtual,abstract

You cannot have a vector of objects of type Action, i.e: vector<Action> because abstract class cannot have instances. You can however have a vector of pointers to abstract class. vector<Action*> This way the polymorphic behavior will be preserved. Note: storing Action instead of Action* would have been an error even...

“Implementation” of the object hierarchy - “the easiest way” or how to avoiding virtual inheritance?

c++,inheritance,virtual,multiple-inheritance,virtual-inheritance

You should definitely avoid a strong coupling of object hierarchy and rendering implementation. My suggestion would be to move all the DirectX specific code to a class outside of your object hierarchy, for example an IRenderer interface together with a DirectXRenderer implementation. Add a reference or pointer to IRenderer to...

Are Virtual Base classes a workable and or useful feature

c++,class,virtual

Virtual inheritance of a class A means that A must be initialized in the most derived class, and access of A things becomes somewhat less efficient (because the A sub-object can be shared between several derived class objects, and thus can be at a dynamic offset in each). For these...

Does final keyword in c++ allow for additional compiler optimizations?

c++,inheritance,virtual,compiler-optimization,final

Yes, the calls can be devirtualized if the virtual function or the class is declared final. For example, given struct B { virtual void f() = 0; }; struct D1 : B { virtual void f(); }; struct D2 : B { virtual void f() final; }; struct D3 final...

How to pass vector object to a virtual function?

c++,function,class,vector,virtual

That little line of code put before declaration of Handling class did the thing. class Car; ...

AutoIt to act as virtual server - is it possible?

networking,server,virtual,autoit

Since you're not asking how (I can't think of legitimate uses), the answer is "Yes it is possible using AutoIt (assuming TCP or UDP protocol is used)". You will not find examples though....

C# pure R6025 virtual function call

c#,function,call,virtual

So i narrowed it down to a COM-Component which seems to have a problem with Windows Server 2012 R2. Because it's a problem with a 3rd Party i've contacted them to fix the problem.

C++ static_cast and virtual method functionality

c++,virtual,static-cast

First: (char*)fixtureAData == "PLATFORM" compares 2 pointers, it does not compare 2 strings. You need to use strcmp or strncmp. This may work if your compiler uses string pooling and fixtureAData is also assigned to the string literal "PLATFORM", but this isn't a good/safe assumption. Second: If you are casting...

Memory location for virtual functions

c++,inheritance,memory-management,virtual

*bas = statbas; // here it crashes Because you dereference bas which is uninitialized and thus you get undefined behaviour. bas = new base; *bas=statbas; // here it works. It also worked with bas=&statbas; It works because bas was initialized on previous row and points to a valid object in...

Operating large numbers of VM's

virtual,virtualization,hypervisor

For the record, everyone, this was solved in a very easy way! We simply created some Python server and client scripts and set them to run on boot. That way we could simply have each VM boot up and wait for a signal on the virtual network. On that signal,...

HowTo write a QML-Keyboard with return value

keyboard,qml,virtual

Each delegate item in a ListView is univocally identified by its index attached property. The first delegate in the list has index 0, then 1 and so on. A ListView has a property currentIndex referring to the currently selected item delegate. When the currentIndex is set to a specific delegate...

C++ Virtual clone method, exception inheritance

c++,oop,inheritance,methods,virtual

You actually need a destructor: virtual ~Auto_Rent_Exception() { } ...

Virtual method being called using base

c#,polymorphism,override,virtual

The virtual keyword is only used to allow a method to be overridden. In C#, by default, methods are non-virtual and you cannot override a non-virtual method. This is the opposite of Java, where all methods are virtual by default. In your case, calling the base implementation of the method,...

Calling true virtual function in base class

c++,multithreading,visual-studio-2010,virtual

You may use something like: threads.push_back(std::thread(static_cast<int (Base::*)(int)>(&Base::getInfo), this, i)); as &Base::getInfo is ambiguous....

Static_cast and virtual methods in c++

c++,virtual,static-cast

static_cast<A>(b) creates a temporary variable of type A constructed from b. So calling name() indeed invokes A::name(). In order to observe polymorphic behavior you may do static_cast<A&>(b).name() ...

EF 6 database first make all properties virtual in generated entity classes

c#,entity-framework,properties,virtual

There is a simple solution. Inside the file, find the CodeStringGenerator class, lookup this method: public string Property(EdmProperty edmProperty) { return string.Format( CultureInfo.InvariantCulture, "{0} {1} {2} {{ {3}get; {4}set; }}", Accessibility.ForProperty(edmProperty), _typeMapper.GetTypeName(edmProperty.TypeUsage), _code.Escape(edmProperty), _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); } One simple edit will be enough: public string Property(EdmProperty...

Unexpected behaviour with a pure virtual function overridden in a derived type [duplicate]

c++,templates,inheritance,virtual,method-overriding

Paul Griffiths nailed it with his comment under my original question: "You can't call a derived class's virtual function from a base class constructor, because at the time it's called the derived class hasn't been constructed yet." That's the critical thing: the call occurs in the constructor, and because the...

Entity Framework - Trouble with one-to-many relationship

c#,entity-framework,lazy-loading,virtual,one-to-many

Question 2: this is because you use the [Required] attribute. In this case you ask to the framework (not only EF) to handle the required constraint. If you want to apply the constraint only at EF level you should use the fluent API: public class testEF : DbContext { public...

Derived Class (Pure virtual C++) [duplicate]

c++,class,virtual,derived

The problem is clear from the error message: you may not instantiate an object of an abstract class. However it seems that there is no need to create an object of the abstract class in the function you showed. As I have understood the function searches an object with the...

C++ Overloading input with abstract class

c++,inheritance,virtual,virtual-inheritance

The problem is in your enter() function. It doesn't change the object itself, but rather creates a new one which is returned via pointer. So when you call input.enter(); in your operator>> overload, the class input refers to is not varied -- and in fact, nothing happens as the pointer...

Polymorphism Trouble in C++

c++,inheritance,polymorphism,virtual,function-calls

The code seems correct, but you don't show you how are populating drawables and the body of addVert. If you could provide a small example that we could compile and run that would be better. It should not be hard for this use case. Note that you don't need to...

Using ToString of parent class without cast in c sharp

c#,string,casting,virtual

You don't need to declare virtual at each level, you only need to do that in the class that declares it, child classes should do override instead. Because ToString() is defined in Object which is what A is implicitly derived from all off your classes should just use override class...

Use of virtual functions in derived classes

c++,inheritance,virtual

I don't see any functions declared virtual in your code. Only virtual functions are resolved at runtime; non-virtual functions are resolved at compile time, according to the static type.

Create a folder in a virtual folder with c#

c#,directory,folder,virtual,createfolder

Physical path is the answer thanks to Paul Zahra.

Multiple Inheritance/Virtual Functions

python,c++,inheritance,virtual,cython

Rather than deleting the old copies of self.thisptr, just make the constructor for the base class only initialize the pointer if the type of self is the base class. def __cinit__(self): if type(self) is PyBaseClass: self.thisptr = new BaseClass() Be sure you guard against deallocation the same way in the...

Understanding linker errors

c++,virtual

The first thing you have to understand here is that a call to foo() made while the constructor of class A is active is dispatched to A::foo(), even if the full object under construction has type B and B overrides foo(). The presence of B::foo() is simply ignored. This means...

Does class have a virtual function? c++ [duplicate]

c++,casting,virtual,virtual-functions

You could test for existence of virtual methods by comparing the size of type with the size of type with a virtual method added. This type of check is not guaranteed by the standard, and can be fooled by virtual inheritance, so it should not be used in production code....

C++ , Why Base class needs a VTable

c++,virtual,vtable

Since R Shau didn't like my edit, I provide my answer highly based on his. VTable is a way to deal with polymorphism. While VTable is a technique widely used by C++ compilers, they are free to provide any other solution. When a base class has one or more virtual...

copy and swap idiom with pure virtual class

c++,class,virtual,copy-and-swap

As your compiler informs you, you cannot create a variable of abstract type. There is no way of dancing around that. This leaves you three main options: Stop using pure virtual functions First, you could just get rid of the pure virtual methods and provide a little stub in each...