class

Passing a smart pointer as argument inside a class: scoped_ptr or shared_ptr ?

I have a class that creates an object inside one public method. The object is private and not visible to the users of the class. This method then calls other private methods inside the same class and pass the created object as a parameter: class Foo { ... }; class A { private: typedef scoped_ptr<Foo> FooPtr; void pri...

Dictionaries in Project Structure

Hello. I am wrapping up an application where I am using a lot of Dictionary classes to store Function and Action delegates. I am now refactoring my project a bit and cleaning code. My question is where do or would you put your Dictionary classes in your project structure? Right now, they are located within the calling class source files ...

Why is this publicly accessible in my example: "MySymbol::TABLE"

class MySymbol TABLE={} def initialize(str) @str = str end def to_s() @str end def ==(other) self.object_id == other.object_id end end class String def my_intern table = MySymbol::TABLE unless table.has_key?(self) table[self] = MySymbol.new(self) end table[self] end end "foo".my_intern In the e...

Explanation of re-usable structures in OO PHP

Can someone please explain "re-usable structures" for me? I was working on making some db objects in php, but was told I was using too much processing from the computer cause I made stuff to complicated with the below objects: My DB objects: $db = new Database; $db->db_connect(); $post_content = new DbSelect; $post_content->select('id...

SetCompatibleTextRenderingDefault in .NET Class Library containing a form

Hi I have a .net class library with a com class that calls a form. I want to to SetCompatibleTextRenderingDefault(false) to ensure the form fonts look nice. If I run the command in the class constructor I get the following error: SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the app...

How can I access variables from another class?

There is probably a very simple solution for this but I can't get it working. I have got multiple classes in my Cocoa file. In one of the classes class1 I create a variable that I need to use in another class class2 as well. Is there a simple way to import this variable in class2? ...

How do I include .class files in my project in Eclipse? (Java)

Hey all. I am working on a project for school where we are given the .class file but not the source to include in our code. I am using Eclipse, and I want to include the file in my project so I can instantiate objects from it and use it. The file is TokenizerImpl.class, and I want to use it like this: TokenizerImpl tokenizer = new Token...

objective-c class variables: when is dealloc called?

If I declare class variables in Objective-C, when is the memory released? If my interface is: @interface TestClass : NSObject { } + (NSString)instanceCount; @end And in the implementation, I declare: static NSString instanceCount; How do I release this class level variable? i.e. when is the dealloc called for class variables in ...

Finding the class with the main method in an applet

I'm trying to use this tool https://swingexplorer.dev.java.net/ to find some information out about an applet's swing structure. Unfortunately, I didn't develop the applet. I've pulled the jars for the applet from the cache, but there are several hundred .class files in the jars, and I don't know which one has the main method. Is the...

c++ class why need main?

Hello I'm writing a little project in c++ where I would like to have some classes that does some work, I wrote the interfaces and the implementation of the classes. The thing that surprises me is that I cannot have a simple class without a main(), I would like to have a class that once instantiated, It's methods can be called, do things...

Imported Java applet project into netbeans won't work, Netbeans refuses to identify or even find main class even when manually set

Hi everyone, I'm trying to set the main class in netbeans to be the main class it was in the last environment it was in, however the program insists it can't find the main class itself and when I set it as the name of the main class in project properties it says the class does not exist (even though it does). When I right click on the ...

Accessing public class memory from C++ using C

Greetings Everyone. I'm currently writing a multi-language programe in C, C++ and fortran on UNIX, unfortunatly I run into "Segmentation Error" when I try and execute after compiling. I've narrowed down the problem to the interface between the C++ and C sections of my program. The first section consists of main.ccp and SA.cpp, and the...

Questions about Structs

MSDN says that a class that would be 16 bytes or less would be better handled as a struct [citation]. Why is that? Does that mean that if a struct is over 16 bytes it's less efficient than a class or is it the same? How do you determine if your class is under 16 bytes? What restricts a struct from acting like a class? (besides disallowin...

Round brackets or not? Whats the difference?

I've seen these two things lately and I'm a bit confused. var blah = new MyClass() { Name = "hello" } and var blah = new MyClass { Name = "hello" } Whats the difference? and why do they both work? Update: Does this mean that if i have something in a constructor which does some computation that i would have to call the first one?? ...

Java class confusion

The word 'class' is used very loosely in Java tutorials and study material. There are many many different meanings to this word. Can some body please enumerate and explain all meanings of this word. E.g.: 'class' means an object, 'class' is an file extension, 'class' is the first word used in declaring object, etc. ...

Scope of static inner class in ASP.NET

I am unsure about the scope of one static inner class of a non-static class. In the lines below, would the variable DataContextCreator.Instance (part of a Singleton pattern) point to the same PDataContext instance for all Page objects/page requests or would each object have its own instance? public class Page : System.Web.UI.Page { ...

Templated assignment operator: valid C++?

Just a quick and simple question, but couldn't find it in any documentation. template <class T> T* Some_Class<T>::Some_Static_Variable = NULL; It compiles with g++, but I am not sure if this is valid usage. Is it? ...

C++: Pointer to class data member

I came across this strange code snippet which compiles fine: class Car { public: int speed; }; int main() { int Car::*pSpeed = &Car::speed; return 0; } Why does C++ have this pointer to a non-static data member of a class? What is the use of this strange pointer in real code? ...

Accessors vs. public members

I have a class with a lot of built-in type members with read/write access. Should I make them public members and provide get/set methods for each one? How about structures? ...

CSS: are class and id interchangeable?

I know others have asked about using class and id in CSS files, such as Div: Class vs Id So I'm aware of the semantic and syntactic differences between class and id: that id should be used for elements that are used only once and class should be used for elements that share attributes in common. But this isn't a hard-and-fast rule, i...