3,464 questions
Score of 1
1 answer
110 views
How to Initialize Array of MutableList in Kotlin
I understand that initializing an array in kotlin is pretty straight-forward if you know the items to put in the array. In my situation, I know how many elements at run time, not during compile time.
...
Score of -2
3 answers
242 views
Can I declare a variable along with a pointer?
Can I declare a variable along with a pointer?
//like this
struct node n1,n2,n3,*start;
//or do i have to do it separately
struct node *start;struct node n1,n2,n3;
to declare variable alongside ...
Score of 4
2 answers
172 views
If a declaration with an initializer is always a definition, why isn't the declaration of a static const member variable a definition?
In The C++ Programming Language 4th edition, in §6.3, page 153, I read
Any declaration that specifies a value is a definition
Again, in §15.2, page 421,
a declaration with an initializer is always ...
Score of 1
0 answers
131 views
What does the C++ standard say about const differences in the declaration and in the definition? [duplicate]
I have a class definition with a method declaration
struct DemoClass{
int operation(int i);
};
and a method definition afterwards
int DemoClass::operation(int const i){
return i+1;
}
the ...
Score of 5
2 answers
331 views
Why was this sentence removed from C23?
I usually referred to C17, but decided to switch to C23.
And looking through the C23 standard, I saw that the sentence from C17 was deleted in C23:
A declaration other than a static_assert ...
Score of 2
3 answers
309 views
How to declare static constexpr variable in C++?
I have a Foo class that includes an array and a static constexpr variable. As a general convention, I want to write public and private variables respectively. But, compiler error occurs 's_array_size' ...
Score of 3
2 answers
158 views
Is initialization an assignment expression?
I found this paragraph in C17(6.7.9 #1):
initializer:
assignment-expression
{ initializer-list }
{ initializer-list , }
initializer-list:
designation{opt} initializer
initializer-...
Score of 3
2 answers
242 views
How do we call this "int * name[4]" using this phrase “derived-declarator-type-list array of T"
In C17 we have this(6.7.6.2 #3):
If, in the declaration “T D1”, D1 has one of the forms:
D [ type-qualifier-listopt assignment-expressionopt ]
D [ type-qualifier-listopt assignment-expression ]
D [...
Score of 13
4 answers
1322 views
Implicit declaration of standard function in C
This question comes from an attempt to understand the "C philosophy" and not from any "real problem".
Suppose that in a C program I use sin(x):
#include <stdio.h>
int main() ...
Score of -2
1 answer
82 views
clang c++ friend user defined literal declare failed [duplicate]
namespace ns {
class MyClass {
private:
int value;
MyClass(int val) : value(val) {}
friend MyClass operator"" _myudl(unsigned long long int val); // Friend UDL declaration
...
Score of 0
3 answers
149 views
Is it wrong to declare simple variables like int, double, bool, var, String, List inside callback function?
Is it wrong to declare simple variables like int, double, bool, var, String, List inside callback function? (Which is generally nested within the build method.)
For, example, I have a ...
Score of 2
1 answer
125 views
What is a declaration outside the template-parameter-list?
In the [basic.scope.temp] section of the C++ standard, it is mentioned:
6.4.9 Template parameter scope
Each template template-parameter introduces a template parameter scope that includes the ...
Score of 0
2 answers
74 views
declare value as having an alias that essentially makes it the same
kind of an odd question, is there a way to lookup a list of values and for the ones that don't exist use an alias and do a lookup on that instead.
matching codes/alias table (say this table doesn't ...
Score of 0
3 answers
1405 views
Why do I need to use the "type" keyword when importing types in Svelte?
I'm coming from the React world, and I'm trying to learn Svelte 5.
Suppose I have the following file:
// types.ts
export interface Person {
name: string;
}
In React, I can import the Person ...
Score of 0
1 answer
110 views
how to solve the incomplete type error in struct declaration
I have a file
#include <stdint.h>
// starting at 0xFFFFFFFF going upwards
uint32_t stackpointers[32];
typedef enum {
READY, BUSY, DONE
}State;
struct TCB_entry {
struct Thread thread;
...