When I allocate a single object, this code works fine. When I try to add array syntax, it segfaults. Why is this? My goal here is to hide from the outside world the fact that class c is using b objects internally. I have posted the program to codepad for you to play with.
#include <iostream>
using namespace std;
// file 1
class a...
I'm confused about the difference between something being a "stereotype" and being a "superclass" in UML.
Let's say I want to create a diagram involving a "WidgetMaker." WidgetMaker is clearly an Actor so the UML standard is to stereotype it actor:
<<Actor>> WidgetMaker
But I grew up programming in the Java/Ruby/C++ world. In that ...
Could someone please explain when would I want to use delegation instead of inheritance?
...
Hello,
I'm working on asp.net
I've written a custom Treenode (customTreeNode) that I use to populate a treeview
the problem comes up when firing the selectnodechanged event
this event give me a TreeNode object and not a customTreeNode
and I cannot seem to cast it somehow,
does sy have a clue ?
Thx
here is the code I have
populat...
I'm trying to subclass str, but having some difficulties due to its immutability.
class DerivedClass(str):
def __new__(cls, string):
ob = super(DerivedClass, cls).__new__(cls, string)
return ob
def upper(self):
#overridden, new functionality. Return ob of type DerivedClass. Great.
caps = super(D...
Here is a complete example.
I want to forbid using A::set from objects casted from B to A by allowing only casting
B to const A.
How to do it?
(I can't use virtual functions)
#include <iostream>
#include <cassert>
using namespace std;
class A {
public:
int get() const { return i_; }
void set(int i) { i_ = i; }
protected:
int ...
In C#, I am developing several Windows Services which have some standard functionality so I have put all this common functionality into a separate referenced utility project.
I have a situation where I need to create instances of business classes which reside in my Windows Service project from the utility project using Activator.CreateI...
A class can be a "subclass" of itself if its inner class extend the outer class
so the class is somehow extending itself without throwing any Exception. So, does it really mean a class is also a subclass of itself?
Thanks.
...
Hi Everyone.
Hope you're having a good Friday and stuff... okay, so here's my question:
All my ASPX pages inherit from a base class called BasePage. BasePage inherits from:
System.Web.UI.Page
Now, how do I access/set a control in my aspx page from my page base? I've tried this:
HyperLink hypMainMenu = (HyperLink)Page.FindControl("...
Okay, so I have torn what I had down and am rebuilding it, here's what I need to do.
I have an entity called Property with:
String name;
@ManyToOne
EntityType type;
??????? value
I need to store a Value too, but depending on the Type, the value could be either a String, a Double, or a link to another object (of Class type.getJavaCl...
I am relatively new to programming with Qt and had a question. Short version:
How do I inherit signals defined in superclasses?
I am trying to subclass someone else's nicely made QTWidgets to change some of the default behavior:
//Plot3D is a QWidget that defines a signal "rotationChanged"
class matLinePlot : public QObject, public...
Consider the following piece of code :-
class A {};
class B : private A {};
B* bPtr1 = new B;
// A* aPtr1 = bPtr1; // error
// A* aPtr2 = static_cast<A*>(bPtr1); // error
A* aPtr3 = (A*)bPtr1;
B* bPtr2 = (B*)aPtr3;
The C-style cast discards the private inheritance while both the implicit and static_cast fail (also dynamic_cast). Why...
Hi
Im declaring a family of static classes that deals with a communications protocol. I want to declare a parent class that process common messages like ACKs, inline errors...
I need to have a static var that mantain the current element being processed and I want to declare it in the parent class.
I do it like this:
parent.m
@implem...
Hi,
i have a MVC project which runs perfectly local. When I deploy to the production server I receive a compilation error:
BC30456: 'Title' is not a member of 'ASP.views_home_index_aspx'.
It makes me think that the inheritance of System.Web.ViewPage(of T) fails somehow... The project is deployed under http://server/ProjectName. The ...
EDIT: Page language is VB
UPDATE
I'm going completely crazy. Here are some screenshots, I hope somebody sees what's going on (TestClass is a simple class with ID and Name property):
View (list, model = IEnumerable)
View (index, no model)
Controller
Resulting page at runtime (list: error)
Resulting page at runtime (index: works)
So...
Somewhat to my surprise, the following code prints out "Close" twice. Running through the debugger, it seems MyPrintStream.close() calls super.close(), which ends up calling MyPrintStream.close() again.
import java.io.*;
public class PrintTest
{
static class MyPrintStream extends PrintStream
{
MyPrintStream(OutputStre...
Let's say you have some 3rd-party library class that you want to extend, simply to add convenience methods to it (so you can call an inherited method with default parameters for example).
Using jUnit/jMock, is it possible to write an assertion / mock expection that tests that the correct inherited method is called?
For example, somethi...
Suppose I have virtual function foo() in class B, and I need slightly different behavior in one of B's derived classes, class D. Is it OK to create an overriding function D::foo(), and call B::foo() from there, after the special case treatment? Like this:
void D::foo()
{
if (/*something*/)
// do something
else
B::foo();
}
...
I have an overridable sub in my base class
Project1:
Public Class BaseClass
Protected Overridable Sub MySub(ByVal Parameter as MyType)
End Class
Project2:
Public Class DerivedClass
Inherits BaseClass
Protected Overrides Sub MySub(ByVal Parameter as MyType)
End Class
MyType is a type that comes from external COM library. W...
I currently have a need for a custom ListViewItem class - let's call it MyListViewItem. It needs to have some additional data associated with each item, and perform some operations when the Checked property is changed. I've tried several things, but currently the relevant code looks like this:
class MyListViewItem : ListViewItem {
...