I wonder if it is a good practice to have a member template function inside a non-template class in c++? Why?
I'm trying to do something like this
in classA.h:
classA
{
public:
member_func1();
member_func2();
};
in classA.cpp:
template <class T> share_func();
classA::member_func1()
{
call share_func();
}
classA::mem...
Ok, so this may be a bit of a silly question, and there's certainly the obvious answer, but I was curious if I've missed any subtleties here.
Is there any difference in terms of visibility/usability between a public member declared in an internal class and an internal member declared in an internal class?
i.e. between
internal class F...
I want to make developing on my new projects easier, and I wanted a bare bones very simple template engine solution. I looked around on the net and everything is either too bloated, or makes me cringe.
My HTML files will be like so:
<html>
<head>
<title>{PAGE_TITLE}</title>
</head>
<body>
<h1>{PAGE_HEADER}</...
I have just created 2 pointers which has undefined behavior and try to invoke a class member function which has no object created ?
I don't understand this?
#include<iostream>
using namespace std;
class Animal
{
public:
void talk()
{
cout<<"I am an animal"<<endl;
}
};
class Dog : public Animal
{
public:
void talk()
...
I'm a bit confused about the object references. Please check the examples below:
class ListHandler {
public:
ListHandler(vector<int> &list);
private:
vector<int> list;
}
ListHandler::ListHandler(vector<int> &list) {
this->list = list;
}
Because of the internal
vector<int> list;
definition, here I would be wasting memory r...
I have a baseclass Event with a DateTime member TimeStamp.
Lots of other event-classes will derive from this.
I want to be able to search a list of events fast, so I'd like to use a binary search.
(The list-data is sorted on timestamp, but there might be duplicate timestamps for events that occurred simultaneously)
So I started out wr...
I have a class Song with properties Title, Key, Artist, etc. There are no methods. I loop through a database of song information and create a Song object for each, populating the properties, and then store the Song objects in an NSArray.
Then I thought, why not just have a struct Song with all those same properties instead of a class So...
Hey. I would like to understand what "class << self" stands for in the next example.
module Utility
class Options #:nodoc:
class << self
def parse(args)
end
end
end
end
Thx!
...
I have a class defined as:
class Obj {
public:
int width, height;
Obj(int w, int h);
}
and I need it to contain a static array like so:
int presc[width][height];
however, I cannot define within the class, so it it possible to create a pointer to a 2D array (and, out of curiosity, 3, 4, and 5D arrays), have that as a member ...
I have a parent class and child class (inherited from parent).
In the child class, I have a member function named function_blah();
I used vector<parent*> A to store 5 parent instances, 3 child instances. So the total number of elements in the vector is 8.
I can easily access to member functions of element A[0] to A[4], which are parent...
I would like to set up a foundation of classes for an application, two of which are person and student. A person may or may not be a student and a student is always a person. The fact that a student “is a” person led me to try inheritance, but I can't see how to make it work in the case where I have a DAO that returns an instance of pers...
Hello All,
I'm a fairly inexperienced programmer, and i'm currently working on a Console Application project. It's basically a little 'mathematics game'; the application generates two random numbers, that have either been added, subtracted, multiplied or divided against each other randomly. The answer is shown on screen and the user has ...
I am accustomed to java.io.* and java.util.* but not to the tree:
com.starbase.util
Class FileUtils
java.lang.Object
|
+--com.starbase.util.FileUtils
Source.
So which class should I import to use the isBinary-method? Do I do "import java.lang.Object;" or "import java.lang.Object.com.starbase.util.FileUtils;"?
...
Why can't I cast a base class instance to a derived class?
For example, if I have a class B which extends a class C, why can't I do this?
B b=(B)(new C());
or this?
C c=new C();
B b=(B)c;
Alright let me be more specific as to what I'm trying to do. Here's what I have:
public class Base(){
protected BaseNode n;
public vo...
Is loading only the needed classes directly a good way of reducing the overall memory usage of a Java application?
For example:
import java.awt.Graphics;
vs
import java.awt.*;
...
I've populated and array with data like this in one class...
PowerClass.h
NSMutableArray pickerArray;
@property (nonatomic, retain) NSMutableArray pickerArray;
-
PowerClass.m
@synthesize pickerArray;
@implementation
NSMutableArray *array = [[NSArray alloc] initWithObjects:@"stef", @"steve", @"baddamans", @"jonny", nil];
pickerArr...
two questions:
how do i compile a .java file that
isn't on my username (like something
in documents or some other sub
folder)
if i have multiple .java files and i
compile one that contains method that
are contained in the others does the
compiler compile those other files.
heres an example of the second question.
example1.java: ...
class UserClass{
#region Class properties which are binding from DB
.
.
.
#endregion
#region Constructor Methods
public UserClass(int _iUser_id)
{
// of course this is wrong but how can i quickly set properties
// which are coming from DB by extension method over context class?
...
Is it achievable in jquery to bind an event to a group of control that has certain class? It seems to me, it can't. I google a bit and all that came up are nothing to do with events. Here's how my code looks -
$('.numonly').bind('keypress',function(event){
if (event.which > 31 && (event.which < 48 || event.which > 57)) return false;...
Let's say I have a class called Medium which can represent different types of media. For instance:
uploaded video
embedded video
uploaded image
embedded image
I represent these types with contants, like this:
class MediumAbstract
{
const UPLOAD = 0x0001;
const EMBED = 0x0010;
const VIDEO = 0x0100;
...