So I have 3 classes.
Abstract class A
Class B extends class A
independent Class C
In class D that contains the main method, I create a list of instances of class B
List<B> b = method-call();` // the method returns a list of instances of class B
Now in class C I have one method that is common to both A and B, and hence I don't want to duplicate it. I want to have one method that takes as input an instance of class A, as follows:
public void some-method(LIst<A> a)
However, when I do:
C c = new C().
c. some-method(b)
I get an error that some-method is not applicable for the argument List, instead it's expecting to get List.
Is there a good way to fix this problem?
Many thanks!
Hi,
is it possible to use date_sub like this ?
$dt = date("Y-m-d h:i:s");
$query = "INSERT INTO `table` (`date`) VALUES ('DATE_SUB('$dt', INTERVAL 15 DAY)')";
$result = MYSQL_QUERY($query);
Thanks
I had inherited this SQL Server where we put data in a table (Call TableA) on a database (DB-A). I can see the tableA in another database on the same server ( DB-B) gets the same data right away.
Any ideas how this is implemented? I am trying to see the trace but so far no luck. Any one has an idea?
At this stage I am not sure if its replication. This is a guess
I have this function:
void ToUpper(char * S)
{
while (*S!=0)
{
*S=(*S >= 'a' && *S <= 'z')?(*S-'a'+'A'):*S;
S++;
}
}
What does it mean for *S != 0, should it be null instead?
Supposed I have the following string:
string str = "<tag>text</tag>";
And I would like to change 'tag' to 'newTag' so the result would be:
"<newTag>text</newTag>"
What is the best way to do it?
I tried to search for <[/]*tag but then I don't know how to keep the optional [/] in my result...
I am using Eclipse IDE for C/C++ Developers, and i am using the gcc to compile at the moment. How can i change it to compile with a Green Hills compiler? Any help will be appreciated. Thanks!
Which is a better way to select ans and quest from the table?
SELECT * FROM tablename WHERE option='ans' OR option='quest'";
OR
SELECT * FROM tablename WHERE option='ans' AND option='quest'";
Thanks so much!
i want to have a background thread in my app that changes an image every 5 seconds for as long as the app is being run. Can someone point me in the direction of how this works? I am new to threads.
Its been a long time since i've done C++ and I'm running into some trouble with classes referencing eachother.
right now I have something like:
a.h
class a
{
public:
a();
bool skeletonfunc(b temp);
}
====================
b.h
class b
{
public:
b();
bool skeletonfunc(a temp);
}
since each one needs a reference to the other i've found I cant do a #include of eachother at the top or i end up in a weird loop of sorts with the includes.
So how can I make it so that a can use b and vice versa with out making a cyclical #include problem.
thanks!
Hello,
I would like to hear your suggestions on kind of design problem which I have in c#.
So, I am making a program where people can meet and draw in the same window over the internet or LAN. I am drawing into a bitmap and than I set it to a pictureBox component.
I have a hard time to decide how to send updates to each user, what is the best way to do it.
Should I send coordinates of mouse and than do the drawing on each users screen or stream the image to each. Maybe you know better solution to keep it synchronized and efficient.
Thank you.
Hello,
In classic MVC the model notifies the view about changes made on it. In C# this means I have to subclass the View I'm interested in and in the subclassed class register to the model's event. For example,
if I were to implement MVC using C# and Winforms, I had to subclass TextBox class and then register inside the MyTextBox's constructor for the model events. Am I correct?
How was this issued in Smalltalk? Does one also need to subclass every View in order to register the model's events, or is there some way to dynamically add events to the views on the fly?
Thanks
I have been given a context schema for a database i need to make for my coursework but some of the attributes (column names) contain letters in brackets at the end of them such as:
*x_Number (Adm)
*x_Number (A)
*x_Number (P)
The problem is i have no idea what these letters mean!
Can anyone help?
hello, can somebody please explain the order of private and public is important or no?
for example:
class Account{
public:
Account(string firstName, string lastName, int id);
void printAccount();
private:
string strLastName;
string strFirstName;
};
will be the same as:
class Account{
private:
string strLastName;
string strFirstName;
public:
Account(string firstName, string lastName, int id);
void printAccount();
};
Hello All,
I have a following ArrayList,
[Title,Data1,Data2,Data3]
[A,2,3,4]
[B,3,5,7]
And I would like to convert this one like this,
[Title,A,B]
[Data1,2,3]
[Data2,3,5]
[Data3,4,7]
I'm bit confused with the approach. Any hint would be much appreciated.
Thanks.
in c or c++
function comlen is defined such
int comlen(char *p,char *q){
int i=0;
while *p && (*p++==*q++)
i++;
return i;
is this code equivalent of this function
int comlen(String s,String m){
int i=0;
while (i<s.length() && s.charAt(i)==m.charAt(i)){
i++;
}
return i;
?
please help
If php and ruby are languages, and cake and rails are frameworks, how do CMS like drupal and joomla fit into the scheme... can you use them in any language and any framework?
Hi,
I have an NSMutableArray called playlist. This is in a method called getAllPlaylists. The code is something like this:
-(NSMutableArray *)getAllPlaylists
{
//playlist is an instance variable
playlist = [[NSMutableArray alloc] init]; //memory leak here
.
.
//some code here which populates the playlist array
[playlist addObject: object1];
.
.
return playlist;
}
The array allocation step of playlist is causing a memory leak. In such a scenario where can i release this array? Or can i avoid allocation n initialization of playlist here by doing something else?
Hi,
I am trying extract number, from line has 'copies : 5' string.
this look behind expression not working.
echo "copies : 5" |perl -ne 'print $1 if /(\d+)(?
Thanks
Hi,
I test some simple F# code for "if" expression, but the result is unexpected for me:
> let test c a b = if c then a else b;;
val test : bool -> 'a -> 'a -> 'a
However
> test true (printfn "a") (printfn "b");;
a
b
val it : unit = ()
I'd expect only "a" is printed out but here I got both "a" and "b". I wonder why it comes out this way? Thanks!