Questions tagged [variable-declaration]

In computer programming, variable declaration specifies properties of a variable (such as its type).

In computer programming, variable declaration specifies properties of a variable:

  • It associates a type and an identifier (or name) with the variable.
  • It allows the compiler to decide how much storage space to allocate for storage of the value associated with the identifier and to assign an address for each variable which can be used in code generation.
663 questions
-3
votes
1 answer

How do I resolve "Use of unassigned local variable" error

For some reason my program gives me an error, telling me "Use of unassigned local variable 'path'", it's really god damn annoying, tried restarting visual studio ( 2017 community ) several times and to no avail, tried to rebuild Solution... nothing…
-3
votes
2 answers

unexpected end of declaration for class variable

I am facing weird error: unexpected end of declaration. And I am very sure that there is no typo. Please help. package test.anyname; import android.app.*; import android.os.*; public class MainActivity extends Activity { boolean ty= true; ty=…
-3
votes
2 answers

Variable Declaration Concept in C

if we declare a variable in C memory is allocated for that variable Or not .My assumption is if we declare variable memory is allocated for that variable but i studied in some sites today Memory is not allocated for variable when we declare. …
-3
votes
1 answer

Why can't I give array elements a value outside of a method in Android Studio?

Before my onCreate() method I can easily declare and initialise data types like int with the code int number = 2; however if I want to do this with an array, using code such as float[] array = new float[2]; array[0] = 1; the second line gives me…
-3
votes
2 answers

Why use type declarations in paretheses for expressions?

I am attempting to learn C by breaking down some source code, line-by-line. I encountered (what I think are) type declarations within parentheses inside of expressions(?) and I'm wondering why this is done. Here are the examples that are throwing…
MSD
  • 544
  • 4
  • 24
-3
votes
3 answers

What is the time complexity of array declaration & definition in C?

What is the time complexity of declaring and defining, but not initializing, an array in C? For what reason is the answer the case? I am interested in the time complexity at both compile and run time, but more so run time. Here is an example of a…
Rob
  • 39
  • 1
  • 5
-3
votes
1 answer

Declaration of a variable

I am new in C programming language and I have a question related to a variable: float a=12.34f; What does "f" stand for? I tried to see what happens if I remove the letter, but I couldn't find anything. The output is the same.
-3
votes
2 answers

Error in iterator declaration for std::map

Declaration works when I declare an iterator like this: map::iterator it, temp; Why doesn't the following work too? maptemp, ::iterator it; error: expected initializer before 'it' Why is this causing an error?
Ali Akber
  • 3,670
  • 3
  • 26
  • 40
-3
votes
2 answers

In Javascript, does it make sense to "declare" a variable that is a property of an object?

I have a global object APP which I use as a namespace for variables and functions in my applicaton: var window.APP = {}; Does it make sense to "declare" variables in this namespace before assigning them? var APP.myvar = null; APP.myvar = new Cls();…
jl6
  • 6,110
  • 7
  • 35
  • 65
-4
votes
1 answer

declaring a variable in C++

I found this in a program. What does it mean? uint8_t x(uint8_t, uint8_t, uint8_t) I'm new to C/C++ and I'm poking around the net to see how others are doing things. I'm sure there's a way to google the answer, but I don't know how to ask the…
joelindo
  • 11
  • 3
-4
votes
1 answer

I have the error CS0136, but I can't find a solution

I have an error saying: (error CS0136: A local or parameter named 'facingRight' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter). I'm a kind of new to this so I don't know what it…
-4
votes
1 answer

C++ - Parentheses after variable name in declaration

I'm looking at some Arduino code and encountering a construct I haven't seen before: CRGBPalette16 currentPalette( CRGB::Black ); CRGB::Black is a constant, which, as some have pointed out is a number. Later on in the code the author appears to…
Tom Auger
  • 19,421
  • 22
  • 81
  • 104
-4
votes
2 answers

I am getting 'users' was not declared in this scope

I can't find what's wrong in my code and tried everything. It's my first time working with maps so I'm not sure this is how I get the value of the second key. This is my code: bool DeleteConnection(ServerData &sd, ServerName sn, UserName…
malaria
  • 77
  • 2
  • 12
-4
votes
3 answers

Declaration of objects vs their assignment in Java

interface Drivable{} class Vehicle implements Drivable{} class Car extends Vehicle{} Vehicle x= new Vehicle(); Drivable x= new Vehicle(); Car x = new Vehicle(); Object x = new Vehicle(); Vehicle[] x = new Vehicle(); how many of those are right? I…
Z Cherry
  • 13
  • 1
-4
votes
1 answer

Variable declaration in java

How I can use the CPU time as variable in java where I need to define a variable with dynamic value increase with time pass example int cpuTime; first: cpuTime = 0 because but after 20 second cpuTime = 20 and after 60 second cpuTime= 60 and so on?…
1 2 3
44
45