Hello all, I'd like to know whether this approach is correct or if their are better ways of doing this.
I have what is basically a Person class which has a number of other classes as variables, each of the custom classes is instantiated by passing the Person ID and then that class retrieves the data it needs using that ID. I expose the ...
Hello,
When starting my application, I have a couple of classes which are required to read certain files in order to create a set of default data.
The logical place (to me) to do this is in a Shared class constructor; the idea would be to throw a class-level event if the reading of the defaults file fails. Unfortunately, this does not ...
Hello,
This isn't valid code:
public class MyClass
{
private static boolean yesNo = false;
static
{
if (yesNo)
{
System.out.println("Yes");
return; // The return statement is the problem
}
System.exit(0);
}
}
This is a stupid example, but in a static class const...
Let's say that I have a class (ClassA) containing one method which calls the constructor of another class, like this:
public class ClassA
{
public void CallClassBConstructor()
{
using(ClassB myB = new ClassB()) {...}
}
}
The class ClassB looks like this:
public class ClassB : IDisposable
{
public ClassB(){}
...
My code does not compile. Below is my code
template <typename T>
class TemplateClass
{
const T constMember;
public:
TemplateClass()
{
constMember = T();
}
};
int main()
{
TemplateClass <int> obj;
}
I get this error :
error: uninitialized member 'TemplateClass<int>::constMember' with 'const' type 'c...