I have a routine that parses text via a loop. At the end of each record I need to clear my string variables but I read that someString = @"" actually just points to a new string & causes a memory leak.
What is the best way to handle this? Should I rather use mutable string vars and use setString:@"" between iterations?
...
Hello, I'm working on a c++ code that uses SDL/opengl.
Is this possible to create a pointer to a quadric with gluNewQuadric() before having initialized opengl with SDL_SetVideoMode?
The idea is to create a class with a (pointer to a) quadric class member that has to be instantiate before the SDL_SetVideoMode call. This pointer is ini...
Hi,
I have a problem.
I try to initialize a variabile in a classViewController created inside a xib file.
I try with the code below but when i append a object to array, these array isn't initialized.
Can you help me?
thanks and sorry for my english.
#import <UIKit/UIKit.h>
@interface AccelerometroViewController : UIViewController <UIAc...
What I want to do: run some prerequisite code whenever instance of the class is going to be used inside a program. This code will check for requiremts etc. and should be run only once.
I found that this can be achieved using another object as static variable inside a constructor. Here's an example for a better picture:
class Prerequisi...
I want to create an 1,k cell of m,m matrices. I have some trouble trying to initialize it. My first idea was to do this
myCell = cell{1,K};
for k = 1:K
myCell{1,k} = eye(m);
end
But it seems like such ugly way to initialize it. There have to be a better way?
...
I have a class MyClass. It has instance variables passedInVar1, passedInVar2, etc. whose values will be passed in from the object that requests the initialization. It also has instance variables decodedVar1, decodedVar2, etc. that will be decoded from an archive -- or set to a default value if there is no archive.
According to Apple,...
Let's suppose you have this class:
class A
{
public:
A () {}
A (double val) : m_val(val) {}
~A () {}
private:
double m_val;
};
Once I create an instance of A, how can I check if m_val has been initialized/defined?
Put it in other words, is there a way to know if m_val has been initialized/defined or not? Something along the li...
I am doing some reviison from the lecture slides and it says a constructor is executed in the following way;
If the constructor starts with this, recursively execute the indicated constructor, then go to step 4.
Invoke the explicitly or implicitly indicated superclass constructor (unless this class is java.lang.Object)
Initialise the f...
Say I have a struct that looks like this (a POD):
struct Foo
{
int i;
double d;
};
What are the differences between the following two lines:
Foo* f1 = new Foo;
Foo* f2 = new Foo();
...
I've got bitten today by a bug.
Question for the C++ lawyers
Let's consider the following source :
struct MyPod
{
short m_short ;
const char * const m_string ;
} ;
MyPod myArrayOfPod[] = { { 1, "Hello" } } ;
int main(int argc, char * argv[])
{
return 0 ;
}
Note that all values are known at compile time, and t...
Hello,
I am new to Python and this is my first time asking a stackOverflow question, but a long time reader. I am working on a simple card based game but am having trouble managing instances of my Hand class. If you look below you can see that the hand class is a simple container for cards(which are just int values) and each Player c...
I have a class, Autodrop, that contains several methods , a.o. 'metadata', that call an external API (dropbox). They are slow.
However, I already often have that metadata around when initializing the AutodropImage, so I should make the methods smarter.
What I have in mind is this:
class Autodrop
include Dropbox
attr_reader :path
...
I'd like to pass null as the default instance of my IFarmManager class using StructureMap. I've currently got the following in my Global.asax:
ObjectFactory.Initialize(x =>
{
x.ForRequestedType<IFarmManager>().TheDefault.Is.Object(null);
};
However, an ArgumentNullException is thrown at runtime:
Value cannot be null.
Parameter n...
Hi, I'm new to C++ and I'm trying to figure out this problem I'm having with my constructor for one of my classes. What happens is... all my variables are initialized properly except two (health and type).
#pragma once
#include <irrlicht.h>
#include <vector>
#include <cassert>
using namespace irr;
using namespace core;
using namespace ...
i would like to initialize database the first time the server is started, that involve calling a class method. Given the class name is: Product
At first i put an .rb file config\initializers\init.rb as it gets automatically called. Everything works ok, until the database is deleted, and i am trying to do rake db:migrate. rake db:migrate...
I'm using SQLite as my database, and I'm a little bit confused about how I'd configure the path to it. Basically, I have a static String in one of my classes ( which, after initialization turns to something like this ):
private static String DATABASE = "db/my.db";
The folder db is located directly under WebContent, so, to get access t...
struct some_struct{
int a;
};
some_struct n = {};
n.a will be 0 after this;
I know this braces form of initialization is inherited from C and is supported for compatibility with C programs, but this only compiles with C++, not with the C compiler. I'm using Visual C++ 2005.
In C this type of initialization
struct some_struct n =...
Hello.
I'm very new on iPhone development. I wondering where to put some custom initialization of an instance variables for my UIViewController.
Can I use initWithNibName:bundle:?
Thanks.
...
Hi there,
is there some way to use a boost tuple's ctors as an addition to the subclass methods (and ctors) like here?
// typedef boost::tuple<int, SomeId, SomeStatus> Conn;
// Conn(1); // works and initializes using default ctors of Some*
struct Conn : boost::tuple<int, AsynchId, AccDevRetStatus> {};
Conn(1); // "no matching function ...
Hey,
where would I place additions to stdlib classes in a rails project? Let's say something like:
class Date
def foo
'foo'
end
end
I thought about the initializer folder but it somehow felt wrong. Ideas?
...