declaration

g++ external reference error

I have issue that is reproduced on g++. VC++ doesn't meet any problems. So I have 2 cpp files: 1.cpp: #include <string> #include <iostream> extern const std::string QWERTY; int main() { std::cout << QWERTY.c_str() << std::endl; } 2.cpp: #include <string> const std::string QWERTY("qwerty"); No magic, I just want place string...

C# assign values of array to separate variables in one line

Can I assign each value in an array to separate variables in one line in C#? Here's an example in Ruby code of what I want: irb(main):001:0> str1, str2 = ["hey", "now"] => ["hey", "now"] irb(main):002:0> str1 => "hey" irb(main):003:0> str2 => "now" I'm not sure if what I'm wanting is possible in C#. Edit: for those suggesting I jus...

Java double initialization

In what way are these statements different? double dummy = 0; double dummy = 0.0; double dummy = 0.0d; double dummy = 0.0D; ...

[C++/Templates] How to use a template parameter in another template parameter declared before

Hello, a template parameter can be used in another template parameter that follows it this way : template<typename T, T N> struct s { }; But is it possible to reference "T" if it is declared after "N" ? This does not work : template<T N, typename T> struct s { }; Can we help the compiler by pre-declaring "T" or doing anything els...

How to understand complicated function declarations?

How to understand following complicated declarations? char (*(*f())[])(); char (*(*X[3])())[5]; void (*f)(int,void (*)()); char far *far *ptr; typedef void (*pfun)(int,float); int **(*f)(int**,int**(*)(int **,int **)); EDIT : After people have cursed me, I am tagging this as homework question. :-) ...

Why is this snippet compilable in C?

Possible Duplicate: In C arrays why is this true? a[5] == 5[a] 3["zdvnngfgnfg"]; ...

__attribute__ in C

Hi, I was just wondering why and how is __attribute__ used in C programs. thanks, ...

Why are variables declared with their interface name in Java?

This is a real beginner question (I'm still learning the Java basics). I can (sort of) understand why methods would return a List<String> rather than an ArrayList<String>, or why they would accept a List parameter rather than an ArrayList. If it makes no difference to the method (i.e., if no special methods from ArrayList are required),...

Automate variable declaration PHP

I want to try and write a function to automate some of the legwork in checking/declaring a variable i.e. function checkVariable($var) { if(!isset($var)||empty($var)) { return ''; } else { return $var; } } $myvar = checkVariable($myvar); obviously, this isn't going to work, because the variable doesn't exist pr...

Java declare array outside variable definition

I'm looking for a way to give a java array a value directly, outside of its declaration, for example /*this works*/ int a[] = {1,2,3}; /*this doesn't*/ a = {1,2,3}; the motivation is so that a method with an array as an argument can be used like this public void f(int a[]) { /*do stuff*/ } f({1,2,3}); instead of int a[] = {1,2,...

Warning in XML Editor on Typed DataSet ".XSC" File

It all about a typed Dataset... The 'urn:schemas-microsoft-com:xml-msdatasource:DataSetUISetting' element is not declared <?xml version="1.0" encoding="utf-8"?> <!--<autogenerated> This code was generated by a tool. Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. </autogener...

What is the difference between int x=1 and int x(1) in C++?

Possible Duplicate: Is there a difference in C++ between copy initialization and assignment initialization? I am new to C++, I seldom see people using this syntax to declare and initialize a variable: int x(1); I tried, the compiler did not complain and the output is the same as int x=1, are they actually the same thing? Ma...

Templates and headers question

The compiler says it can't find the reference for the function when I do this: // link.h template <class T> T *Link(T *&, T *(*)()) // link.cpp template <class T> T c:Link(T *&ChildNodeReference, T *(*ObjectCreator)()){ } If I implement inside the class on the header it goes smoothly. Please, I will work on the header until som...

C# Class function members declaration & implementation

Is there a concept in C# of class definition and implementation similar to what you find in C++? I prefer to keep my class definitions simple by removing most, if no every, implementations details (it depends on several factors as you may know, but generally I move towards leaving most member implementation details outside the class def...

Problem with method defined in VC++ header file

I have a class in a DLL that's used in many other DLLs and EXEs. It has a couple of methods defined in the include file (i.e. the method body is in the .h file) that's included in the other binaries. One of them is giving me fits: int GetVersion() { return nVersion; }. It is always returning -842150451, but when I run in the debugg...

Simple C array declaration / assignment question

In higher level languages I would be able something similar to this example in C and it would be fine. However, when I compile this C example it complains bitterly. How can I assign new arrays to the array I declared? int values[3]; if(1) values = {1,2,3}; printf("%i", values[0]); Thanks. ...

Initialization Error in CSharp

I have a Type set up as follow class Program { static void Main() { IEnumerable<int> one = new int[] { 1, 2, 3, 4, 5, 6, 7 }; IEnumerable<int> two = new int[] { 12, 34, 56, 7, 8 }; MySet[] sets = new MySet[] { new MySet{ MySetID =100, MySubSet=new MySubSet{SubSet=new List<int>().AddRange(one), SubSet...

What happens to a declared, uninitialized variable in C? Does it have a value?

Quick question-- if in C I write: int num; Before I assign anything to num, is the value of num indeterminate? ...

final arraylist declaration

when i declared final arraylist() then can i perform insert,search and update operation in that arraylist or not??please reply me... thanks in advance ...

C Puzzle - play with types

Please check the below program. #include <stdio.h> struct st { int a ; } fn () { struct st obj ; obj.a = 10 ; return obj ; } int main() { struct st obj = fn() ; printf ("%d", obj.a) ; } Following are the questions What is the output of the program? Where is ';' terminating the declaration of 'struct st'? By ISO IE...