declaration

'[Class name]' does not name a type in C++

女生的网名这么多〃 提交于 2019-11-30 23:31:27
I am programming a graph using a list of lists. For that, I have two classes, and each one of this classes has a pointer to another object of the same class and a pointer to the object of the second class. Here is the code: File V.h: #ifndef VERTICEPUNT_H #define VERTICEPUNT_H #include "A.cpp" typedef char E; class V { public: E etiqueta; V* siguiente; A* primera; //<- Error: 'A' does not name a type V(); ~V(); }; #endif // VERTICEPUNT_H File V.cpp: #include "V.h" V::V() { etiqueta = ' '; siguiente = 0; primera = 0; //<- Error: 'primera' was not declared in this scope } V::~V() { delete

how to declare a variable in Netezza?

情到浓时终转凉″ 提交于 2019-11-30 23:14:32
I have a Netezza query where I reference a couple of dates in a series of case statements. Instead of replacing all of these dates every time I'd like to declaire a variable at the beginning and use that throughout the query. In SAS I'd do it like this: %LET end_p = '31DEC2014'd; proc sql; create table want as select distinct id, sum(case when (INCUR_DT) >= (&end_p-30) and ip_op_cd = 'IP' then net_allow_at else 0 end) as ip_d_30, sum(case when (INCUR_DT) >= (&end_p-90) and ip_op_cd = 'IP' then net_allow_at else 0 end) as ip_d_90, sum(case when (INCUR_DT) >= (&end_p-180) and ip_op_cd = 'IP'

Why is the C++ variable declaration syntax inconsistent?

℡╲_俬逩灬. 提交于 2019-11-30 22:42:05
问题 when I declare C++ variables, I do it like this: int a,b,c,d; or string strA,strB,strC,strD; I.e., first the type then a comma separated list of variable names. However, I declare pointers like this: int *a,*b,*c,*d; and references like this: int &a,&b,&c,&d; To be consistent it should be int* a,b,c,d; and int& a,b,c,d; Why is it not consistent? 回答1: It's because of the C heritage. The * modifier applies to the variable in C. So the C++ designers made & to apply to the variable as well by

java class declaration <T>

◇◆丶佛笑我妖孽 提交于 2019-11-30 22:34:24
I'm familiar with simple class declaration public class test but I don't understand public class test<T> . < T > refers to a generic type. Generic types are introduced in Java to provide you with compile time, and this is important due to type erasure, type-safety. It's especially useful in Collections because it frees you from manual casting. It is a good idea to read more on generics, especially the documentation on the topic by Angelika Langer is very good: http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html I assume that HTML ate your <T> (you need to write <T> to display it) T

Why should member variables be initialized in constructors?

蹲街弑〆低调 提交于 2019-11-30 21:39:22
When I first started working with object-oriented programming languages, I was taught the following rule: When declaring a field in a class, don't initialize it yet. Do that in the constructor. An example in C#: public class Test { private List<String> l; public Test() { l = new List<String>(); } } But when someone recently asked me why to do that, I couldn't come up with a reason. I'm not really familiar with the internal workings of C# (or other programming languages, for that matter, as I believe this can be done in all OO languages). So why is this done? Is it security? Properties? If you

Why is it possible to declare a variable without an initial value?

对着背影说爱祢 提交于 2019-11-30 20:36:43
I'm reading Gilles Dowek's Principles of Programming Languanges : He says that it's also possible to declare a variable without giving it an initial value and also that we must be careful not to use a variable which has been declared without an initial value and that has not been assigned a value. This produces an error. Note: The book's author mentions the possibility of declaring variables without an initial value on Java. So, why is this declaration of variables valid? When am I going to use it? There are many different reasons for many different languages. MEMORY When you declare a

C++/CLI : Advantages over C#

微笑、不失礼 提交于 2019-11-30 19:05:19
Is there any major advantage of managed C++/CLI over C#. Definitely not the syntax I suppose as the following code in C++/CLI is real ugly, C++/CLI code: [Out]List<SomeObject^>^% someVariable Compare above with C# Code: out List<SomeObject> someVariable Just out of curiosity, is there an even uglier syntax in C++/CLI as compared to the above. It's almost exclusively an interopability language - both for allowing .Net code to access legacy C++ libraries, or for extended existing (native) C++ code bases with access to .Net libraries (and some variations on these themes). While it is possible to

Is it possible to create a type alias to a generic class in Delphi

最后都变了- 提交于 2019-11-30 18:43:16
I would like to define a class type (type alias) for a generic class. I would like to do this so users of unit b can have access to TMyType without using unit a. I have units like this: unit a; interface type TMyNormalObject = class FData: Integer; end; TMyType<T> = class FData: <T>; end; implementation end. unit b; interface type TMyNormalObject = a.TMyNormalObject; // works TMyType<T> = a.TMyType<T>; // E2508 type parameters not allowed on this type implementation end. I already found a possible workaround which I don't like because it can introduce hard to find bugs: TMyType<T> = class(a

Declarations, definitions, initializations in C, C++, C#, Java and Python [closed]

隐身守侯 提交于 2019-11-30 18:30:37
What do the terms mean in each of the above languages? Why do the languages differ (wherever they do, if at all they do) in this respect? C/C++: A declaration is a statement that says "here is the name of something and the type of thing that it is, but I'm not telling you anything more about it". A definition is a statement that says "here is the name of something and what exactly it is". For functions, this would be the function body; for global variables, this would be the translation unit in which the variable resides. An initialization is a definition where the variable is also given an

how to declare a variable in Netezza?

前提是你 提交于 2019-11-30 18:27:59
问题 I have a Netezza query where I reference a couple of dates in a series of case statements. Instead of replacing all of these dates every time I'd like to declaire a variable at the beginning and use that throughout the query. In SAS I'd do it like this: %LET end_p = '31DEC2014'd; proc sql; create table want as select distinct id, sum(case when (INCUR_DT) >= (&end_p-30) and ip_op_cd = 'IP' then net_allow_at else 0 end) as ip_d_30, sum(case when (INCUR_DT) >= (&end_p-90) and ip_op_cd = 'IP'