Questions tagged [declaration]

Declaration is the part of the subprogram (procedure or function) which provides the protocol(header), but not the body of the subprogram.

3407 questions
1
vote
0 answers

class declaration in exec inits class, but functions don't work

I am going to attach two blocks of code, the first is the main code that is ran the second is the testClass file containing a sample class for testing purposes. To understand what's going on it's probably easiest to run the code on your own. When I…
mizuprogrammer
  • 225
  • 3
  • 10
1
vote
1 answer

Make struct accept any type insted of float

I'd need to modify a simple struct to accept multiple types of value parameters, as shown below: struct menuitems_t { menuitems_t(std::string name, float* value = 0, int itemtype = menuitemtype::SWITCH) { this->name = name; …
John
  • 13
  • 2
1
vote
1 answer

FreeRTOS static array declaration with a macro identifier

I am learning FreeRTOS from scratch. In order to do that,first, i start to investigate Task.c file. In that file there are macros, functions and declarations. But I am confused about the declaration meaning and i cant figure it out why? In task.c…
Nazim
  • 406
  • 1
  • 6
  • 20
1
vote
6 answers

Why can I write some things out-of-order in python but not others?

Please have a look below: a = 5 print a + b b = 4 When I try to run the code above, it gives an error: Traceback (most recent call last): File "C:/Users/user/Documents/modules/ab.py", line 2, in print a + b NameError: name 'b' is not…
alwbtc
  • 28,057
  • 62
  • 134
  • 188
1
vote
4 answers

Good use cases for declaring enum type tags and variable names in C?

If you need some constants in your code you can declare them with enums: enum { DOG, CAT, FISH, }; enum { CAR, BUS, TRAIN, }; and then use DOG, BUS, etc. as needed. But enums may be declared in a more verbose style as…
Theo d'Or
  • 783
  • 1
  • 4
  • 17
1
vote
1 answer

Losing some values while passing 3D array as a parameter C

I am writing a program where I am passing 3d array as a parameter to a function remove_red() but after the second row, the values in the array are being overwritten by some random numbers. This is the code: void remove_red(int image[100][100][3],…
1
vote
1 answer

Class member function unable to access a private struct node of the same class?

I was working on a homework assignment and I stumbled upon a roadblock I created a linked list class that looks something like this List.h class List{ struct Node{ string data etc... } public: Node* lastNode(Node*…
AlexDong11
  • 11
  • 1
1
vote
2 answers

Scope of using namespace versus using namespace closure

I'm trying to understand why there is ambiguity in my functions when I use using namespace versus explicitly declaring a namespace enclosure. Book.h header file: #ifndef MYBOOK_BOOK_H #define MYBOOK_BOOK_H namespace mybook { void showTitle(); …
S. Trahl
  • 99
  • 8
1
vote
2 answers

How to correctly declare/assign values for variables in c++

Should I declare variables at the top of my c++ program before assigning values: int i; std::string x; std::string retval; x = "foo"; i = 5; retval = somefunction(); Or alternatively is it correct/acceptable to assign values to variables the…
asd plougry
  • 143
  • 1
  • 9
1
vote
1 answer

How to access components created in Xamarin.Forms C# code behind?

So, I'm doing an app in Xamarin.Forms that creates some components and layouts when a button is clicked. My problem is that I need to access these components afterwards so I can change the text in some labels, get values from editors and remove…
1
vote
2 answers

Parse in and return 2D array

Trying to make a tic-tac-toe game and having trouble with the grid, I'm new to C and have looked everywhere but nothing seems to work. int main(void) { char grid[GRID_HEIGHT][GRID_WIDTH]; grid = make_grid((char **)grid); print_grid((char…
aLongBoat
  • 59
  • 9
1
vote
2 answers

How can I resolve the "cout was not declared in this scope" error?

just a simple program but can anyone point out why this error is occuring, (i am using dev C++ version 5.11) #include #include class animal { public : void sound(); void eat() ; }; void animal::eat() { …
M Desmond
  • 113
  • 1
  • 3
1
vote
5 answers

RandomAccessFile cannot be found by compiler after being declared

The code below produces the following error when I try to compile it: cannot find symbol symbol : variable airplanesFile The error is produced by the last statement. Why can the RandomAccessFile object not be found after it's…
mg11
  • 11
  • 1
1
vote
4 answers

Regex for variable declaration and initialization in c#

I want to write a RegEx to pull out all the variable values and their names from the variable declaration statement. Say i have int i,k = 10,l=0 i want to write a regex something like int\s^,?|(^,?)* but this will also accept k = 10 i.e. (without…
Anirudh Goel
  • 4,571
  • 19
  • 79
  • 109
1
vote
1 answer

Difference between wrapping a value and explicitly declaring value as a type in Swift

I came across a heterogeneous dictionary definition like this on a tutorial online: var mixedMap4 = [AnyHashable(0): "Zero" as Any, AnyHashable(1): 1.0 as Any, AnyHashable("pi"): 3.14 as Any] I was wondering why…
tiw
  • 535
  • 1
  • 6
  • 22