I've got the following classes:
class A {
void commonFunction() = 0;
}
class Aa: public A {
//Some stuff...
}
class Ab: public A {
//Some stuff...
}
Depending on user input I want to create an object of either Aa or Ab. My imidiate thought was this:
A object;
if (/*Test*/) {
Aa object;
} else {
Ab object;
}
Bu...
I have an organization that has clients and students, every student begins as a client.
If I have a Client class and a student class that inherits from client. How do I make a client a student?
...
So, there is going to be one login form; however 1 of 3 types of members will be signing in member_type_a, member_type_b, member_type_c all of whom have some of the same properties, and some whom may have specific methods and/or properties to them. I want the class to be saved to a session variable for use with member area pages.
Any s...
As I understand it, when a new class is instantiated in C++, a pointer to the new class is returned, or NULL, if there is insufficient memory. I am writing a class that initializes a linked list in the constructor. If there is an error while initializing the list, I would like the class instantiator to return NULL.
For example:
MyCla...
Is it possible to get the memory-allocated address of a newly instantiated class from within that class's constructor during execution of said constructor? I am developing a linked list wherein multiple classes have multiple pointers to like classes. Each time a new class instantiates, it needs to check its parent's list to make sure i...
I have a class MyClass which is templated on typename T. But inside, I want a method which is templated on another type TT (which is unrelated to T).
After reading/tinkering, I found the following notation:
template <typename T>
class MyClass
{
public :
template<typename TT>
void MyMethod(const TT & param) ;
} ;
For st...
Hi,
So I'm working on creating a visualization for a data structure in Java. I already have the implementation of the data structure (Binary Search Tree) to start with, but I need to add some additional functionality to the included node class. As far as conventions and best practices are concerned, should I create a subclass of the n...
Hello Guys,
How will I use an instance of an object that is initially loaded throughout the whole site?
I want $myinstance to be used everywhere.
$myinstance = new TestClass();
Thanks!
...
I want to use the append() function from inside the <head>, in a function to be specific, like so:
function custom_img(src_img)
{
$("div").append("<img src='"+src_img+"'>");
}
var myimg = new custom_img("test.jpg");
This is a quick example that I just wrote out. I want my function to make a new image like that every time I create a n...
Hello there,
I am creating a class in C# which eventually will be part of a library that other users can use.
A user of this class has to set some properties and then use a public method to retrieve the results. What shall I do when a user calls the method without setting all the properties? Throw exception and expect the user to catch...
I have got this little snippet of code, I want to be able to define each array element as a new data member.
class Core_User
{
protected $data_members = array(
'id' => '%d',
'email' => '"%s"',
'password' => '"%s"',
'title' => '"%s"',
'first_...
Hello
If have a new project (ProjNew ) where I want to put several classes that are on other project (ProjOld).
The problem is I want to maintain the old classes marked with Obsolete to avoid running all my projects and check if they using it.
But in that way this may throw a ambiguous class name error because I didn't explicitly cal...
I should start by saying I'm not now, nor do I have any delusions I'll ever be a professional programmer so most of my skills have been learned from experience very much as a hobby.
I learned PHP as it seemed a good simple introduction in certain areas and it allowed me to design simple web applications.
When I learned about objects,...
Ok, just wondering on the versions of PHP that this class is built into. And if they are built into all platforms (OS's). I'm wanting an approach to search through a zip file and place files using file_put_contents in different filepaths within the webroot. In any case, I'm familiar with how to do this with the ZipArchive class, but I...
Hi, this is Oben from Turkey.
I work for my homework in C++ and i have some problems with multiply definitions.
My graph class ;
class Graph{
private:
string name; //Graph name
fstream* graphFile; //Graph's file
protected:
string opBuf; ...
Ok, so I'm still learning the ropes of C++ here so I apologize if this is a simple mistake.
I have this class:
class RunFrame : public wxFrame {
public:
RunFrame();
void OnKey(wxKeyEvent& keyEvent);
private:
// Configuration variables.
const wxString *title;
const wxPoint *origin;
const wxSize *size;
const...
Is it possible in C# to get types of subclasses from base class?
...
There are several duplicates of this but nobody explains why I can use a member variable to store the pointer (in FOO) but when I try it with a local variable (in the commented portion of BAR), it's illegal. Could anybody explain this?
#include <iostream>
using namespace std;
class FOO
{
public:
int (FOO::*fptr)(int a, int b);
int ad...
Some Java APIs provide a large number of interfaces and few classes. For example, the Stellent/Oracle UCM API is composed of roughly 80% interfaces/20% classes, and many of the classes are just exceptions.
What is the technical reason for preferring interfaces to classes? Is it just an effort to minimize coupling? To improve encapsul...
How do I get a variable's type in c? Objective c has className, php has get_class(), etc...
...