Questions tagged [datamember]
204 questions
2
votes
1 answer
WCF Service Implementation
I've scoured the internet, several books, and even consulted some peers. Nothing really states if what I'm attempting to do is bad practice or not. The short; is I'm just doing a fire-and-forget from the client.
[ServiceContract]
public interface…

Greg
- 11,302
- 2
- 48
- 79
2
votes
1 answer
A class as data member of another class
I have two classes A and C, where I need to have object of C in class A as a private member. This is the basic structure I have and I have following issues:
1. How can I create the itsC object in constructor?
2. I am getting following error…

kaja
- 55
- 3
- 9
1
vote
3 answers
Inherited member function accessing data members
Consider the sample code below:
#include
using namespace std;
class A
{
private:
static int a;
int b;
protected:
public:
A() : b(0) {}
void modify()
{
a++;
…

nitin_cherian
- 6,405
- 21
- 76
- 127
1
vote
2 answers
CollectionDataContract serialization not adding custom properties (DataMember)
We have a legacy system that needs to be fed (XML) data in a most unstructured format. Is the following even possible with the .NET DataContractSerializer?
Given the following DataContracts
[CollectionDataContract(Name = "Options", ItemName =…

Tawani
- 11,067
- 20
- 82
- 106
1
vote
2 answers
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?
Example of assignment at instantiation:
class…

Carter Canedy
- 73
- 1
- 9
1
vote
1 answer
Why C++ non-static data members require unique addresses?
Recently C++ has added the feature [[no_unique_address]] for empty data types such as struct empty {};.
How do empty data memberes benefit from having a unique address?
Why wouldn't the standard make all empty data members address-less?
Why C++…

Arjonais
- 563
- 2
- 17
1
vote
1 answer
WCF Deserialization resets DataMember value to default after OnDeserializing callback
I have developed a WCF Service Application hosted in IIS 7.5 targeting .NET 3.5 configured with only a basicHttpBinding endpoint. The OperationContract signature consists of a Composite type where one of its properties is a custom type. When this…

confuzed
- 13
- 3
1
vote
2 answers
Standard says, we can define static data member template like class template and function template, but how exactly?
The chapter of Templates in the C++03 Standard starts with the following:
A template defines a family of classes or functions.
template-declaration:
exportopt template < template-parameter-list > declaration
template-parameter-list:
…

Nawaz
- 353,942
- 115
- 666
- 851
1
vote
1 answer
.net core 3.1 upgrade : DataContract and DataMember - unable to hide a field
I have a class with
[DataContract]
public class Request
{
[DataMember]
public int Id{get; set;}
//calculated field
public int Salary{get; set;}
[DataMember]
public int Name{get; set;}
}
I was able to hide field "Salary" by not…

Dev
- 1,451
- 20
- 30
1
vote
2 answers
Why is my inherited method outputting Base class' member instead of derived class' member
I am trying to print the member 'age' from the Mum class which inherits the method print_age() from Dad, but it is printing the member 'age' from Dad's class
#include
#include
using namespace std;
int main()
{
class Dad
{
…

keker_keker
- 15
- 3
1
vote
1 answer
Initialising member aggregate type without copy-constructor
I need to initilise an member array of a class with a non-default constructor and without using the copy constructor.
I have the following two classes:
class MemberClass
{
public:
MemberClass(int id) { /* Do stuff */ }; // Define non-default…

Owen Binchy
- 11
- 1
1
vote
0 answers
Why would modifying a vector data member of set cause this program to run infinitely?
So, I have this struct called store:
struct Store
{
int position = -1; //graph position of that store node. Since all stores that are given as input have required fish_types
//it would be useless to try to reduce the number using some id…

Stanton Dobson
- 51
- 4
1
vote
2 answers
Does resetting Data members count as duplicate code?
I'm rather new to programming and Java specifically. I'm currently building a game with a Ship object. It has the following data members;
int START_M_ENERGY = 21;
int START_C_ENERGY = 1;
int STARTING_HEALTH = 5;
int maximalEnergyLevel =…

Omri. B
- 375
- 1
- 13
1
vote
2 answers
How do pointers to members in C++ work internally?
I am trying to know how pointers to members work in C++.
I looked at some places, and found that they store some sort of offset. And use the fact that members occur in memory in the same order in which they are declared in the class/structure…

Jeevesh Juneja
- 212
- 2
- 9
1
vote
2 answers
What is the difference between assigning an instance variable before and after parameter?
What is the difference between assigning a parameter to an instance variable? Why is it wrong when you write the parameter before the instance variable?
int variable;
void set(int parameter)
{
variable = parameter;
parameter = variable;…

Abdelrahman Yousf
- 25
- 1
- 4