Usually like this:
#include <boost/assign/std/vector.hpp>
vector<int> v;
v += 1,2,3,4,5;
Except for a:
#include <boost/ptr_container/ptr_vector.hpp>
boost::ptr_vector<int> v;
If you need to know the reason; I'm using ptr_vector instead of vector only so I don't have to delete elements, but I need to initialize it using Boost.Assign...
Hi,
I have in my header "Test.h" a variable of a class that doesn't have a constructor without arguments.
And I have a constructor like this:
Test::Test() // <-- Here he complains:
// error: no matching function for call to ‘Beer::Beer()’
{
int i = 2;
theVar = Beer(1, i); // Beer(int, int) is the only constructor
}
...
Hello,
Can i initialize structure if other structure? For example: I have structure:
typedef struct _JobParam
{
MainWin* mw;
}JobParam;
Where MainWin structure too.
In main code i have function:
Can the so-initialize structure or it's wrong way?
void load (MainWin* mw)
{
Param param;
param.mw = mw;
}
Thank you
...
Suppose I have a class with private memebers ptr, name, pname, rname, crname and age. What happens if I don't initialize them myself? Here is an example:
class Example {
private:
int *ptr;
string name;
string *pname;
string &rname;
const string &crname;
int age;
public:
E...
Is there a way to declare first and then initialize an array in C?
So far I have been initializing an array like this:
int myArray[SIZE] = {1,2,3,4....};
But I need to do something like this
int myArray[SIZE];
myArray = {1,2,3,4....};
...
My Silverlight application needs one parameter, an integer. In my Html, I have written:
<param name="InitParameters" value="UserId=1" />
In code I am reading the parameters in:
foreach (KeyValuePair<string, string> pair in e.InitParams)
{
Resources.Add(pair.Key, pair.Value);
}
e.InitParams is always empty. Any ideas?
...
I have read that there are good reasons to use properties instead of fields in c# on SO. So now I want to convert my code from using fields to using properties.
For an instance field of a class, I can set a default value. For example:
int speed = 100;
For the equivalent property, which I think is:
int Speed { get; set; }
My unders...
I am so used to work in PHP with multi-dimensional arrays, where I can assign and initialize a hash by
unset($a); // just to show that there is no variable $a
$a['settings']['system']['memory'] = '1 Gb';
$a['settings']['system']['disk space'] = '100 Gb';
Is there a way to do similar thing in Ruby? Or I need to initialize all dimension...
Hi all -
Using a Python array, I can initialize a 32,487,834 integer array (found in a file HR.DAT) using the following (not perfectly Pythonic, of course) commands:
F = open('HR.DAT','rb')
HR = array('I',F.read())
F.close()
I need to do the same in ctypes. So far the best I have is:
HR = c_int * 32487834
I'm not sure how to initi...
http://www.ama3.com/anytime/
$(".pick_date").AnyTime_picker({ format: "%W, %M %D, %z" });
This is code to initialize AnyTime picker on .pick_date element. But if I append element then AnyTime doesn't work on it. Is there a way to make it work.
I tried this:
$('#submit-buton').live("click", function() {
$.ajax({
type: "P...
I'm using maven war plugin to build war package.
Before package is build test are executed. To preinitialize my database with sample data I use spring bean. I would like to have different data in my db for tests and different when application starts.
I was thinking that maybe it is possible to use two different spring initializer class...
Hello everybody
Which static class initialize first if we have one more static classes in our project?
For example : Below code gives null exception.
class Program
{
static void Main(string[] args)
{
First.Write();
Second.Write();
}
}
static class First
{
public s...
Hi,
I am creating a software project in which most business objects are stored in files (in a legacy format). The objects will only be instantiated from an inputstream.
I do this today with making the constructor private and instantiating in a static function as follows:
public class BusinessObject {
private BusinessObject() {}
...
Using g++ to declare function-static thread-local storage:
void f() {
static __thread somePodStruct thing;
...
}
can I assume that thing will get zero-initialized?
...
I would like to initialize several auto-vivifying hashes by one-line expression. So far I came to an extra method for the AutoHash object:
class AutoHash < Hash
...
def few(n=0)
Array.new(n) { AutoHash.new }
end
which allows me to do the following
a, b, c = AutoHash.new.few 3
However, I feel that one can make the followin...
I am trying to block access to the default constructor of a class I am writing. The constructor I want others to use requires a const reference to another object. I have made the default constructor private to prevent others from using it. I am getting a compiler error for the default constructor because the const reference member var...
How do you deal with them? I have some classes (usually classes that hold stats etc.) with some 20+ variable members, and the initialization lists end up very long, extending beyond the page width if I don't manually wrap around. Do you try and break down such classes or do you deal with this in some other way?
It doesn't look very tid...
Hello,
How can I initialize a structure if one field in the structure is itself a structure?
Thank you.
...
I have a situation where I need to use some strings temporarily but I've read so many conflicting things that I'm a bit confused as to what the best way to proceed is.
I need to assign some strings inside an if structure but use them outside the if structure so they need to be created outside the if, I was thinking something like:
NSSt...
I have a Django model Reminder related to Event model.
class Reminder(models.Model):
email = models.EmailField("e-mail")
event = models.ForeignKey(Event, unique=True, related_name='event',)
date = models.DateTimeField(_(u"Remind date"), auto_now_add=False,)
class Event(models.Model):
date = models.DateTimeField(_(u"Even...