class

question regarding "this" pointer in c++

hello there, i have been given class with int variables x and y in private, and an operator overload function, class Bag{ private: int x; int y; public: Bag(); ~Bag(); //....... //.....etc }; Bag operator+ (Bag new) const{ Bag result(*this); //what does this mean? result.x += new.x; resul...

Why data members are private by default in C++?

Hi, Is there any particular reason for having all data members in a class as private by default in C++? Thanks, Naga ...

Subclassing and adding data members

I have an hierarchy of classes that looks like the following: class Critical { public: Critical(int a, int b) : m_a(a), m_b(b) { } virtual ~Critical() { } int GetA() { return m_a; } int GetB() { return m_b; } void SetA(int a) { m_a = a; } void SetB(int b) { m_b = b; } prot...

C++ struct, public data members and inheritance

Is it ok to have public data members in a C++ class/struct in certain particular situations? How would that go along with inheritance? I've read opinions on the matter, some stated already here http://stackoverflow.com/questions/952907/practices-on-when-to-implement-accessors-on-private-member-variables-rather-than http://stackoverflow...

Calling Model Functions from a Library

Hello all, I have turned a normal PHP class into a library so I can use it in Codeigniter as a library. I can load it and call the functions I need in that class. Here is that class to help with the question. However, there are quite a few points where I have to call functions in my class. These functions reside in the model that inst...

Make instance of class in java at runtime

In my program I generate classes dynamically but when I try: String[] args = {"-d","D:\\path\\build\\classes","-s","D:\\path\\src","http://services.aonaware.com/DictService/DictService.asmx?WSDL"}; WsImport.doMain(args); URL url = new URL("file:D:/path/build/classes/com/aonaware/services/webservices/"); URLClassLoader urlClassLoader = n...

C# object creation from datatable

I'm just getting my head round C#. I've been creating classes and objects so say i created a class called Member: public class Member { public int MemberID; public string FirstName; public string LastName; public string UserName; } and I create a new object of that class by doing this: Member Billy = new Me...

Java: Protected classes?

I'd like to be able to have two protected classes in my package. That is, I do not want files outside of my package to see them as visible - they will be for internal use within the package only. How can I do this? ...

How to move a struct into a class?

I've got something like: typedef struct Data_s { int field1; int field2; } Data; class Foo { void getData(Data& data); void useData(Data& data); } In another class's function, I might do: class Bar { Data data_; void Bar::taskA() { Foo.getData(data_); Foo.useData(data_); } } Is there a way to move the Data ou...

Jquery hasClass conditional not working

Hey, I have my site going here: http://www.treethink.com I am trying to make it so when a navigation item is clicked, it retracts the news ticker on the right and then doesn't run any of the extracting/timer functions anymore. I got it to retract but it still extracts. How I am doing it is I am adding a "noTicker" class with the nav ...

Jquery removeClass Not Working

Hey, My site is here: http://treethink.com What I have going is a news ticker on the right that is inside a jquery function. The function starts right away and extracts the news ticker and then retracts it as it should. When a navigation it adds a class to the div, which the function then checks for to see if it should stop extracting/...

Java: Why is this Subclass valid?

Here, I have an abstract class: abstract class A<E extends A> { abstract void foo(E x); } Here's a class that extends A: class B extends A<B>{ void foo(B x){} } And here's another (E is B here on purpose): class C extends A<B>{ void foo(B x){} } Both of those classes are valid, and the reasoning for that makes sense ...

Call plugin class in Java

How can I call a class in Java, when the name of the class won't be known at compile time (such as if it were a plugin). For example, from a GUI, a user selects a plugin (a Java class), the application then creates a new instance of the class, and calls one of its methods (the method name would be known at compile time (e.g. "moduleMain"...

Python Introspection: How to get varnames of class methods?

I want to get the names of the keyword arguments of the methods of a class. I think I understood how to get the names of the methods and how to get the variable names of a specific method, but I don't get how to combine these: class A(object): def A1(self, test1=None): self.test1 = test1 def A2(self, test2=None): ...

Is it bad practice to use the namespace to identify the verb or should it always be in the class name?

For example is MyLibrary.Data.Import.Hotels Bad Vs MyLibrary.Data.Import.ImportHotels Or even MyLibrary.Data.ImportHotels ...

I serialized a C++ object, how to allocate memory for it without knowing what type it is?

Hello, I have serialized a C++ object and I wish to allocate space for it, although I can't use the "new" operator, because I do not know the object's class. I tried using malloc(sizeof(object)), although trying to typecast the pointer to the type the serialized object is of, the program shut down. Where is the information about the obje...

Using a class within a class?

I built myself a MySQL class which I use in all my projects. I'm about to start a project that is heavily based on user accounts and I plan on building my own class for this aswell. The thing is, a lot of the methods in the user class will be MySQL queries and methods from the MySQL class. For example, I have a method in my user class t...

Xerces C++ SAX Parsing Problem: expected class-name before '{' token

I'm trying to run through an example given for the C++ Xerces XML library implementation. I've copied the code exactly, but I'm having trouble compiling it. error: expected class-name before '{' token I've looked around for a solution, and I know that this error can be caused by circular includes or not defining a class before it is ...

Help design a class diagram of a booking system

Hello guys, I got a request from my friend to write a php booking system module for his bowling club website, I am thinking to make this module as generic as possible, ie can also be used for booking pool tables etc. So I started to draw up my UML class diagram: I have 2 interfaces IBookingHandler(has implementation like BowlingBookin...

How to propagate .java file change to .class under eclipse, tomcat & stripes

Hi, i'm new to java and i got some problems. i'm developping a web application using the framework stripes on tomcat 6.0. I'm working with eclipse EE on windows. i successfully managed to get the stripes example application (called Bugzooky) up and running on my tomcat server. I imported the .war file and stripes libs in Eclipse. Here is...