I have the following class in C++:
class a {
const int b[2];
// other stuff follows
// and here's the constructor
a(void);
}
The question is, how do I initialize b in the initialization list, given that I can't initialize it inside the body of the function of the constructor, because b is const?
This doesn't work:
a::a(void) :
b([2,3])
{
// other initialization stuff
}
Edit: The case in point is when I can have different values for b for different instances, but the values are known to be constant for the lifetime of the instance.
I have the following class:
class Seller
{
private string sellerName;
private decimal price;
}
~propreties for SellerName and Price goes here~
I also have a list of sellers:
list<Seller> s = new list<Seller>();
How can I get the maximum value of price out of all the sellers?
Thank you very much.
I have a Class A that when it is instantiated and saved for the first time or modified it will create an instance of Class B and save it also
I want them to be in the same transaction and I want it to be handled in the Model not a controller.
I know how to do this in a conteoller with the ‘transaction do’ block but how do I do it in the model?
Thanks
I have a level class and a Enemy_control class that is based off an vector that takes in Enemys as values.
in my level constructor I have:
Enemy tmp( 1200 );
enemys.Add_enemy( tmp ); // this adds tmp to the vector in Enemy_control
enemys being a variable of type Enemy_control. My program crashes after these statements complaining about some destructor problem in level and enemy_control and enemy.
Any ideas?
Hi
I have a table structure something like this
table Employees
EmployeeID
EmployeeLogin
EmployeeCustID
table Customers
CustomerID
CustomerName
What i would like is to map the structure above to one single class named:
Class Employee
EmployeeID
EmployeeLogin
EmployeeName
How do i do that with fluent nhibernate ?
I've sometimes seen code like this:
class Something(object):
class Else(object):
def __init__(self):
pass
def __init__(self):
# Do something with self.Else...
pass
Is it a good idea to define classes inside related classes? Is this an acceptable way to group related code?
i ve been tryin to find an soln to a question that i m unable to get for few days... the prob s that the data has to be taken from datagrid and should be passed to another class and in that class i have to store in database..
plz guyz
help me out
thanx in advance..
How do I represent integer array as attribute of a class in Visual Studio 2010's UML class diagrams? I know hot to add normal integers, but I'm hoping that there is a way to do it other than adding [] to integer's name.
I'm new to UML, so I could be missing something obvious here.
Should I use Is ordered and Is unique?
I have a base class that declares a grouping of objects. That grouping can be an array, List, Collection, that's up to me.
The derived classes of this base class are the ones that actually set the values of this multi-element field. What is the best way to expose this field to the derived classes?
Is there a way to annotate an anonymous inner class in Java?
In this example could you add a class level annotation to Class2?
public void method1() {
add(new Class2() {
public void method3() {}
});
}
I'd like to access the stage of the main timeline from w/i a class that extends a movieclip. Basically, I have a button in the main timeline that makes a HUD appear. The HUD is an extended MovieClip class. When people click on a button in the HUD, I'd like to remove the object from the stage of the main MovieClip.
Please advise me the difference between two ways of declaration of java constructor
public class A{
private static A instance = new A();
public static A getInstance() { return instance;
}
public static void main(String[] args) {
A a= A.getInstance();
}
}
AND
public class B{
public B(){};
public static void main(String[] args) {
B b= new B();
}
}
Thanks
I have a list of class names and methods that can only be read during runtime. Is it possible to create a class dynamically like that? I'm currently using C# 4.0.
Hello.
I like the VS option of Add Class that creates .cpp and .h file for me with a class template in it. But currently i am storing my source files in other folder than project file. Is there a way to to tell VS that i want to create those .cpp and .h files in a specific folder?
What would be an elegant way to implement the functionality of this nested class in F#?
private class Aliaser {
private int _count;
internal Aliaser() { }
internal string GetNextAlias() {
return "t" + (_count++).ToString();
}
}
This was my first attempt, but it feels like there should be a sexy one-liner for this:
let aliases = (Seq.initInfinite (sprintf "t%d")).GetEnumerator()
let getNextAlias() =
aliases.MoveNext() |> ignore
aliases.Current
See following class:
function availItem(xs, s, m, l, xl) {
this.xs = xs;
this.s = s;
this.m = m;
this.l = l;
this.xl = xl;
}
How can I declare the above class using JSON? I think It should be in following manner but problem is to pass argument.
var availItem = {
xs : xs,
s : s,
m : m,
l : l,
xl : xl
}
Two quotes from the C++ standard, §1.8:
An object is a region of storage.
Base class subobjects may have zero size.
I don't think a region of storage can be of size zero. That would mean that some base class subobjects aren't actually objects. Opinions?
hello.
Is it possible to specify alignment of parent class?
for example something like (which does not compiled):
template<size_t n>
class Vector : public boost::array<double,n> __attribute__ ((aligned(16)))
{
thanks
I'm trying to extend a Java Swing component in Clojure, i.e. I want to extend a javax.swing.JComponent and add some custom methods implemented in pure Clojure in addition to all the standard inherited methods.
I've tried using "proxy" which works great if I just want a single instance (in the same way as an anonymous inner class). However I'd really like a named class so that I can generate an arbitrary number of instances.
What's the recommended way of doing this?
Hello,
I have a class library (in C#). I need to encode my data using the HtmlEncode method. This is easy to do from a web application. My question is, how do I use this method from a class library that is being called from a console application?
Thank you!
How to declare a static dictionary object inside a static class? I tried
public static class ErrorCode
{
public const IDictionary<string , string > ErrorCodeDic
=new Dictionary<string, string>()
{
{"1","User name or password problem"}
};
}
But the compiler complains that "A const field of a reference type other than string can only be initialized with null".
Hello, I want to do someoperations after click on row, except td with class='someClass'
$('#mainTable tr td:not([class=someClass])').unbind().live('click',function ()
{
//some operation
});
what is wrong?
note: this td is not last td in table.
The first print shows the member value to be false, and the other two prints show it as true. Why does the first output differ from the last two?
#include
#include
using namespace std;
class MyClass
{
public:
bool value;
bool stuff;
};
class Container
{
public:
vector my_classes;
Container()
{
MyClass c;
cout