class

Class variable within its definition?

This is probably a dumb question. I am trying to make a text-mud. I need each Room class to contain other Room classes that one can refer to when trying to move to them or get information from them. However, I can not do that because I obviously can not declare a class within its definition. So, how do I do this? Here's what I mean when ...

C++ Classes with android

The android NDK supports c++, but does it support c++ classes?? If so can you give a simple example and the steps needed to implement the class with the java source. ...

In C++, initialize a class member with 'this' pointer during construction.

Hi everyone. I'd like to create a class that is associated to another class in some sort of parent-child relationship. For this the "child" class needs a reference to it's parent. For example: template <typename T> class TEvent { private: T* Owner; public: TEvent(T* parent) : Owner(parent) {} }; class Foo { private: TEven...

Getting NullPointerException when accessing a variable in a Java class

Hi guys, I have a problem when setting a variable inside a Java class Here is my code This is where I create the instances (IdeaInfo is a class that acts similar to a Struct): IdeaInfo[] IDEAS = new IdeaInfo[100]; String[] TITLES = new String[100]; This is the function that will use those instances: try { while ((line ...

uml classdiagram constructor with parameters

I am a complete ROOKIE at this so I need some help on it. How would you create uml class diagram and constructors with parameters. for default (no parameters) you do policyholder() for diagram and pseudo-code for parameters would you do the same thing policyholder (policynumber, service class, and customer age) for class diagrams an...

How can I improve on this. (Breadcrumbs class)

Hi, I have recently created a breadcrumbs class that fits in with our in-house CMS and it works as I intend but I have a nagging feeling it could have been done better. I was thinking of doing an array_pop close to the end of the construct but I decided to go with an IF statement instead, what do you guys think? (Oh also $_REQUEST['sec...

Application structure

Hello, I have such classes: class Base { private: bool mEnabled; public: bool getEnabled() { return mEnabled; } }; class First : public Base; { // ... }; class Second : public Base { Second() { // I have to check First::mEnabled } }; class Manager { First obj1; Second obj2; }; I have some class manager...

Linq-to-SQL: property without a storage column

hey, there, is there any way to ass a NON DB property to a Linq-to-SQL class? (etc calculated fields), I'm getting an error when trying ...

Using enumerations

Hello, I can't understand one problem: Types.hpp: enum SomeEnum { one, two, three }; First.hpp: #include "Types.hpp" class First { public: void someFunc(SomeEnum type) { /* ... */ } }; Second.hpp: #include "Types.hpp" #include "First.hpp" class Second { public: void Foo() { First obj; obj.someFunc(two); // tw...

Drupal: If statement for page.tpl.php (Depending on page section)

I want to use the if statement to select specific pages that have <body class="section-category"> and output custom content for only those pages. My PHP is not very good and I hope this is a very simple task to do. Can anyone give me a tip? ...

Can I pass arguments into a model function?

Is it even possible to do something like this in codeigniter?Is it considered a good practice in general? ...

loading resource file in class library and know which resource file to use

I have a class library and was to add a resource file to it to support both English and Spanish. Any tips as how I can do this? The language will be dictated by the user visiting the site. Would like to have to only load each resource file once and cache or set in static variable and avoid any overheads. ...

c++ socket stream api

I'm using what looks to be a real nice API for streaming sockets found here: http://www.pcs.cnu.edu/~dgame/sockets/socketsC++/sockets.html. I'm having trouble accessing the IP of the connected user because its a private member of a class "Socket" that is used within another class "ServerSocket". My program looks exactly like the demo on...

'this' is undefined in JavaScript class methods

I'm new to JavaScript. New as far as all I've really done with it is tweaked existing code and wrote small bits of jQuery. Now I'm attempting to write a "class" with attributes and methods, but I'm having trouble with the methods. My code: function Request(destination, stay_open) { this.state = "ready"; this.xhr = null; th...

Calling the first declaration of foo from an extended class that declares it's own foo.

<?php class a { public function foo() { echo __METHOD__ . PHP_EOL; } } class b extends a { public function foo() { $this->foo(); # I want to call a's foo method here. echo __METHOD__ . PHP_EOL; } } class c extends a { public function foo() { echo __METHOD__ . PHP_EOL; $this->foo...

python class inherits object

Is there any reason for a class declaration to inherit object? I just found some code that does this and I can't find a good reason why. class MyClass(object): # class code follows... The code is using swig for binding some C code to Python, if that's relevant. ...

how to dynamically create methods to operate on class objects initialized at runtime

I have a class, say class AddElement{ int a,b,c; } With methods to set/get a,b,c... My question is definitely a logic question - say I implement AddElement as follows: int Value=1; Value+=AddElement.get_a()+AddElement.get_b()+AddElement.get_b(); Now imagine I want to do the above except 'a,b,c' are now arrays, and instead of '...

c++ class pointer deletion segfaulting

I've got a simple class called object that I'm having a problem with. Theres one method which causes a segfault if I call it. I don't understand why. typedef class object { private: short id; std::string name; SDL_Rect offset; public: object(); object(short i, std::string n); ~object(); o...

How do you first find a class that contains a string and then get the id of the element with that class you just found? Using Javascript.

What I'm trying to do is search a page for an element that has the string 'tab_selected' in the class name. The class name is more than just 'tab_selected'. Its 'tab_selected + the UUID'. The UUID changes so all I really want to search for is if the class name contains 'tab_selected' and then if it does I want to get the ID of that eleme...

How can I make an alias to a non-function member attribute in a Python class?

I'm in the midst of writing a Python Library API and I often run into the scenario where my users want multiple different names for the same functions and variables. If I have a Python class with the function foo() and I want to make an alias to it called bar(), that's super easy: class Dummy(object): def __init__(self): pass...