Questions tagged [datamember]
A data member in object-oriented programming is a class member which holds data. In Java, it is called "field". Colloquially, it is sometimes called "member variable".
datamember
209
questions
0
votes
1
answer
102
views
Question about C++ pointers in a class instance declared as const [duplicate]
If i were to create a simple class like this:
class foo
{
int* a;
};
and then create an instance of that class that is const:
const foo;
would foo's member a be a const int* or a int* const?
I feel ...
1
vote
1
answer
52
views
makeNode function. what's wrong with it?
I created 2 struct dl and Node. I used struct dl for created Node and created function makeNode. Please help me! Thanks you guys read it.
typedef struct _dl {
char ProblemID[10];
char ...
4
votes
2
answers
620
views
What is the difference between C++ "data member" and "field"?
I am translator in company and often we have problem to understand the difference between the terms "data member" and "field".
Could you please describe what they are and how they ...
1
vote
3
answers
216
views
How to lazy init class member without a default constructor
How do I lazy init class members without a default constructor?
Here is the minimum reproducible example:
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;...
0
votes
2
answers
52
views
How to sum up properties' values from datamember in C#?
I have an event class defined as the following:
[Serializable]
[DataContract]
public class BaseEvent
{
[DataMember]
public int count { get; set; }
[DataMember]
public SubEventClass ...
0
votes
2
answers
156
views
How to remove unused data-members?
The following code contains an example template X, where the data-member is unused, if the template is parametrized with other type than A. But the sizes of the objects a and b are the same, even with ...
0
votes
0
answers
207
views
Most efficient way to mutate data member
I've been wondering about this question for a long time. What is the most idiomatic and / or efficient way to assign a new value to a data member (mutation)? I can think of 3 options:
Mutate directly ...
1
vote
2
answers
981
views
Assigning a class variable in class definition versus at class instantiation
What are the ramifications of assigning a class variable when defining the class versus in the class constructor? Is the variable assigned in the class definition accessible by all class instances?
...
2
votes
2
answers
111
views
confusion of address of a pointer
I see a piece of code like this:
#include<stdio.h>
struct person{
int age;
float weight;
};
int main(){
struct person *personPtr, person1;
personPtr = &person1;
printf("...
0
votes
2
answers
2k
views
Store the details of employee and display the max salary using c++
I am trying to create a program that stores the data of employees and then displays the highest salary employee separately.
Here, What I had tried.
#include <iostream>
#include <limits>
#...
-1
votes
1
answer
30
views
Is writing data members inside ctor more pythonic? [duplicate]
My limited experience in python shows that
class Person:
def __init__(self):
self.data: Tuple[int, str] = (5, "M")
print("DONE")
is more common than
class ...
0
votes
2
answers
735
views
Is constructor called in before the data members in C++
Hello i am new to learning C++.
Is constructor created in the order i create it in the class or is it always called first before anything else is created in the class.
#include <iostream>
using ...
0
votes
0
answers
36
views
what is the point of using [Datamember] in c#? [duplicate]
I've been looking this up but I just can't seem to understand the point or the advantages of using it when should I use it?
0
votes
0
answers
404
views
Devexpress report : table repeating C#
I have a report. I have created a table at design time and data is filled at runtime. When it's run, two tables are created for two rows. Either I need all data rows in one table row or add multiple ...
2
votes
1
answer
366
views
Restrict use of instance variable to single method in C#
I want to be able to restrict usage of a instance variable to one method, and other usages should not be possible (compile error, or warning). For instance
public class Example
{
public string ...