void

Are class constructors void by default?

喜夏-厌秋 提交于 2019-12-21 21:21:49
问题 I have been reading on class constructors in C#. Examples are showing overloaded class contructors. And all of them do not have a void keyword and neither they have a return value.. e.g. public Class myClass { public myClass() { } public myClass(int id) { } //other class memeber go here... } 1) So is it correct to say C# constructors are void by default? 2) Does the same applies to Java as well? 回答1: no, they are constructors, if anything, you can think of them as returning an object of the

How to use .NET reflection to determine method return type (including void) and parameters?

旧城冷巷雨未停 提交于 2019-12-21 09:36:42
问题 how to know the number and type of parameters? how to know the return type? how to check whether the return type is void? 回答1: Use MethodInfo.ReturnType to determine the return type, and MethodBase.GetParameters() to find out about the parameters. ( MethodInfo derives from MethodBase , so once you've got the MethodInfo via Type.GetMethod etc, you can use both ReturnType and GetParameters() .) If the method is void , the return type will be typeof(void) : if (method.ReturnType == typeof(void))

warning: control reaches end of non-void function [-Wreturn-type]

你。 提交于 2019-12-20 07:55:54
问题 I got a piece of code such that: int check(int d, char arr[9][9], int rep_arr[45][3]) { int p = findProb(d, arr, rep_arr, 0) ; if (isIdeal(d, arr) == 1) { print_array(d,arr) ; return 1 ; } else if(isIdeal(d,arr) == 0 && p == 0){ printf("Fail\n") ; return 0 ; } else if (isIdeal(d, arr) == 0 && p != 0) { #do something recursively.. } where isIdeal(d, arr) can only be equal to 0 or 1 and p can be equal to 0 or another integer . However, the compiler gives me the error that given in the title.

How is “void()” useful?

落爺英雄遲暮 提交于 2019-12-20 04:24:28
问题 You cannot declare a void variable: void fn() { void a; // ill-formed } Yet this compiles: void fn() { void(); // a void object? } What does void() mean? How is it useful? Why is void a; ill-formed, while void() OK? void fn() { void a = void(); // ill-formed } 回答1: The statement void(); creates a void value and then discards it. (You can't actually do much with a void value other than discard it or return it.) The standard† says in 5.2.3 [expr.type.conv The expression T(), where T is a simple

Void methods cannot return a value

Deadly 提交于 2019-12-20 03:25:55
问题 I'm following the CS106A lectures online. I'm going through the code on Lecture 12, but it's giving me errors in Eclipse. This is my code. It seems the error is because of the word void in my main method. I tried deleting the main method, but of course Java can't run without it. I'm a newbie and no one has explained what the String[] args thing really means, but I've been told to just ignore it and use it. I'd appreciate if someone could explain that to me as well. This errors also comes up

In Java, can “void” be considered a primitive type?

自古美人都是妖i 提交于 2019-12-19 12:50:26
问题 I've noticed eclipse JDT uses void as a primitive type. Can this be considered correct? 回答1: I find that, in cases like this, you can't beat going to the Java Language Specification. It is pretty clear about the fact that void is not a primitive. First off, void is not in the list of primitive types. Later on, the JLS explicitly states: the Java programming language does not allow a "cast to void" — void is not a type http://java.sun.com/docs/books/jls/third_edition/html/statements.html#5989

How to check if a void* pointer can be safely cast to something else?

若如初见. 提交于 2019-12-19 09:09:49
问题 Let's say I have this function, which is part of some gui toolkit: typedef struct _My_Struct My_Struct; /* struct ... */ void paint_handler( void* data ) { if ( IS_MY_STRUCT(data) ) /* <-- can I do something like this? */ { My_Struct* str = (My_Struct*) data; } } /* in main() */ My_Struct s; signal_connect( SIGNAL_PAINT, &paint_handler, (void*) &s ); /* sent s as a void* */ Since the paint_handler will also be called by the GUI toolkit's main loop with other arguments, I cannot always be sure

What is void** in C#?

五迷三道 提交于 2019-12-19 05:46:13
问题 I'm looking through the source of a C# program that uses a library written in C. I came across this line and was unsure what it was: cvbimUNSAFE.GetImageVPA ((cvbim.IMG)cvImg.Image, 0, (void**)&lpImageBits, &pVPAT); What is an object of type void ** ? I did some Google searches and could only find information about void* , which is a pointer to a sort of catch all top level type, if I understood correctly. 回答1: It's a pointer to a pointer to something not specified. Basically, just think of

How bad is to use void pointer in std::vector declaration?

戏子无情 提交于 2019-12-19 04:55:33
问题 I have two different classes as below: class text { }; class element { }; And I want to store them in the class node : template <typename T> class node { T cargo; std::vector<void*> children; node(T cargo) : cargo(cargo) { }; void add_child(T node) { this->children.push_back((void*) node); } } So I would call the node this way storing both, text and element 's: element div; text msg; node<element> wrapper(div); wrapper.add_child(msg); EDIT : To get back the content I use T typedef type; and

Can a C# lambda expression ever return void?

落花浮王杯 提交于 2019-12-18 19:45:35
问题 I have the following method, and I want to know if there is anything that can go in place default(void) below because there is a compiler error that says that void is not valid here: private void applyDefaultsIfNecessary(ApplicationConfiguration configuration) { var defaults = new Dictionary<Predicate<ApplicationConfiguration>, Action<ApplicationConfiguration>>() { // { rule, action } - if rule is true, execute action { (c) => c.ConnectionString == null , (c) => c.ConnectionString = "foo" },