variable-initialization Questions

9

Solved

I'm curious to know the difference between declaring a variable, and initializing a variable. e.g. var example; // this is declaring var example = "hi" // initializing? Or just "adding a value"? ...

11

Solved

I'm declaring some strings that are empty, so it won't throw errors later on. I've read that this was the proper way: string Camnr = Klantnr = Ordernr = Bonnr = Volgnr = Omschrijving = Startdatum...
Pallaton asked 14/11, 2012 at 7:13

2

Solved

This is my small program: enum Type { b = 1, c = 2 }; int main() { Type b = b; std::cout << b << std::endl; return 0; } Which outputs 0. Can I conclude that the above definiti...

2

Solved

While writing a template, I want to initialize my variable to a value that serves as zero or null the the data type. If I set it to 0x00 is it going to serve as zero/NULL for any type ? for exampl...
Penick asked 5/1, 2016 at 1:18

4

Solved

When I call Functions to get a value, I usually initialize varible, in case function fails or doesn't return anything and I want to avoid dealing with uninitialized variable. I do the same for stri...
Dysthymia asked 25/11, 2015 at 22:45

5

Solved

Is there a nice way to stop the repetition of task from within the task itself when running in a ScheduledExecutorService? Lets say, I have the following task: Future<?> f = scheduledExecut...

2

Solved

To the best of my knowledge, there are three ways to initialize a variable in C++. int x = 0; // C-like initialization int x (0); // Constructor initialization int x {0}; // Uniform initialization...
Callicrates asked 25/7, 2014 at 10:30

4

Solved

I have the following code: int *numberArray = calloc(n, sizeof(int)); And I am unable to understand why I receive the following error. Cannot initialize a variable of type 'int *' with an rvalu...
Chittagong asked 15/6, 2014 at 8:10

4

Solved

I have this simple line of code: int x; x automatically has the value of 1. I don't set it to anything but when I debug, it shows that x is 1. Does an int have a default value of 1?!
Homologate asked 12/5, 2011 at 15:48

5

Solved

To my surprise, I found that the name of a c++ object can be the same as class name. Can someone explain to me the reason why? When I declare an object of class a as a a1(), it does not raise an e...
Frizzle asked 8/10, 2013 at 14:33

1

Solved

I'm fairly new to queries which involve variable declaration in MySQL. I have seen various styles and I'm not fully clear of what these actually do. I've questions about what these actually do. 1)...

4

Solved

In an article about how objects are initialized in Java there was a paragraph which is given below: At the beginning of an object's life, the Java virtual machine (JVM) allocates enough memory ...
Puccini asked 3/11, 2012 at 6:30

5

Solved

Here are two way to initialize class variables. 1st Method class Test { private $var1; private $var2; public function Test($var1,$var1) { $this->var1 = $var1; $this->var2 = $var2; } ...
Housewifery asked 16/3, 2011 at 7:18

5

Solved

I have two different tables in my database, and each are displayed to the user based on their "SortOrder". I have written two functions that take a row (or entity) and swaps its sort order with the...
Surpass asked 28/6, 2011 at 18:6

7

Solved

Which do you prefer and why" String myString = null; if(someCondition) myString = "something"; else myString = "something else"; OR String myString = ""; if(someCondition) myString = "someth...
1

© 2022 - 2024 — McMap. All rights reserved.