declaration

What is the purpose of forward declaration?

what is the description or meaning of this: for example: class test; class test { ..... }; ...

implicit class variable declaration in php?

Hi, I've been looking at some code and am having a hard time working out variable declaration in php classes. Specifically it appears that the code i'm looking at doesn't declare the class variables before it uses them. Now this may be expected but I can't find any info that states that it is possible. So would you expect this: class E...

How are these ObjC declarations different: ie what is this really doing?

I'm trying to understand what this is doing in each case. Can someone explain what the first case is doing in detail and how it differs from the second? Thanks // :) //declare in first case NSManagedObjectModel *mom(); NSManagedObjectModel *mom() { static NSManagedObjectModel *mom = nil; //implementation goes here... return mom; } ...

Problem with structures, where to put them and how to reference them in headers?

OK, I'm in a dilemma right now, and neither my knowledge of C (which isn't the biggest one anyways) nor the almighty Google seem to be able to help me with this: I have some structures for a game prototype: Map (Uhhm... the Map..) Chara (A base for Enemies the Players) Player (The Player) Now the problem is: Map needs a refere...

member function pointer which returns same type of member function pointer

Hello, I'd like to declare a member function pointer in C++, that returns the same member function pointer type This doesn't work: class MyClass { public: typedef FunctionPtr (MyClass::*FunctionPtr)(); } Does someone know a solution? ...

Can a JavaScript object property refer to another property of the same object?

I recently tried to create an object like this: var carousel = { $slider: $('#carousel1 .slider'), panes: carousel.$slider.children().length }; My intentions were to improve jQuery's selector performance by caching the results of $('#carousel1 .slider') in an object property, and to keep the code concise and relatively...

Constant declaration in Ada

Being new to Ada, I'm exploring its syntax and rules and I would like to draw attention on the code given next. Here I'm trying to set a variable Actual_Stiffness to hold a constant value. Its value is given by the product: Actual_Stiffness := Stiffness_Ratio * Stiffness_Total where Stiffness_Total has been defined to be a constant L...

iphone declare property correctly

Hi all, I have this problem: I have my code into my view that connect to internet to retrieve some info and populate a uitableview, and works fine.. To make order to my code I created my class derived to nsobject and I added all my code inside it... the table is populated, but the app retrieve bad_access... I think that the problem is th...

C# recursive delegate declaration problem

* PLEASE SEE END FOR IMPORTANT EDIT * For various reasons I have something like: delegate void Task(QueueTask queueTask); delegate void QueueTask(Task task); Using Visual Studio Express 2008 this works more or less fine apart from in lambda expressions where it can't deduce if I try call and call queueTask() in the function without ...

Declaring and initializing variable in for loop

Can I write simply for (int i = 0; ... instead of int i; for (i = 0; ... in C or C++? (And will variable i be accessible inside the loop only?) ...

Function and declaring a local variable

Just having an conversation with collegue at work how to declare a variables. For me I already decided which style I prefer, but maybe I wrong. "C" style - all variable at the begining of function. If you want to know data type of variable, just look at the begining of function. bool Foo() { PARAM* pParam = NULL; bool rc; ...

Strict mode in PHP?

Hey, Other languages with automatic variable declaration - like Perl - have a strict mode. By activating this strict mode, variable declaration is required, and Perl throws an error as soon as you try to use an undeclared variable. Does PHP offer any similar feature? Thx ...

Redundancy in OCaml type declaration (ml/mli)

Hello, I'm trying to understand a specific thing about ocaml modules and their compilation: am I forced to redeclare types already declared in a .mli inside the specific .ml implementations? Just to give an example: (* foo.mli *) type foobar = Bool of bool | Float of float | Int of int (* foo.ml *) type baz = foobar option This, ac...

C multiple single line declarations

What happens when I declare say multiple variables on a single line? e.g. int x, y, z; All are ints. The question is what are y and z in the following statement? int* x, y, z; Are they all int pointers? ...

Declaring two variable in a conditional?

Can I declare two variables in a conditional in C++. The compiler gave an error but still I think I should get an opinion: int main() { double d1 = 0; if((double d2 = d1) || (double d3 = 10)) cout << "wow" << endl; return 0; } ...

Forward declaring classes in namespaces

I was rather surprised to learn that I couldn't forward declare a class from another scope using the scope resolution operator, i.e. class someScope::someClass; Instead, the full declaration has to be used as follows: namespace { class someClass; } Can someone explain why this is the case? UPDATE: To clarify, I am asking why t...

C++: declaring a class with functions, that handle string

Hello, I haven`t found answer to my question using search, though I thought it is simple and popular. Anyway, my question is: I have got a header file, which declares a class and functions in it. It looks like that: #ifndef SOME_CLASS_H #define SOME_CLASS_H #include <string> class mySomeClass { public: bool a_func(string & my...

QMapIterator declaration of several lists problem

i'm having 3 types of lists, and i'm trying to print them according to attribute_type. so according attribute_type the iterator is chosen. the problem is if for example attribute_type == "pis", the if condition is executed but when finished it returns to the upper decleration: QMapIterator it(pit.item_parameters), so this way the iterato...

Detecting declared package variables in perl

Given # package main; our $f; sub f{} sub g {} 1; How can I determine that $f, but not $g, has been declared? Off the cuff, I'd thought that *{main::g}{SCALAR} might be undefined, but it is a bona fide SCALAR ref. Background: I'd like to import a variable into main::, but carp or croak if that variable is already declared. EDIT Ad...

How to use enum within a struct in ANSI C?

Following code has to be used in the main-function, but I don't know how it is used. struct SomeItem { enum {MOVIE, MUSIC} itemType; union { struct Movie* movie; struct Music* music; }; }; this struct is used in a dynamic linked list with previous/item/next pointer, but I don't know how you can set the enum...