Questions tagged [datamember]

204 questions
2
votes
1 answer

Why is compiler throwing "expected a type specifier"?

class A { private: int a; public: int get_a() { return a; } A(int mode) { a = 0; } A() { a = 5; } }; class B { public: A b(0); }; class C { int c; public: C(int mode) { c = 0; …
luka_bur3k
  • 367
  • 1
  • 2
  • 11
2
votes
2 answers

What is handy way to modify the private class data members without writing explicit setters? Are templates useful?

I have a class with data members. class Sph { public: Sph( float radius , float segments , const Shader& shader ); Sph(const Sph& geometry); Sph& operator = (const Sph& geometry); ~Sph(); void init(); void CleanUp(); void…
user8028736
2
votes
4 answers

Where is local variable of member function created if object is created via new?

Class A { int a; int get_a() { int d; return a; } }; A* obj_a_ptr = new A; int c = A->get_a(); Where is int d memory allocated , in heap or stack ?
Amruth A
  • 66
  • 5
  • 17
2
votes
1 answer

DataMember's name

Is it possible somehow to add DataContract/DataMember attributes for existing binary classes (available only as compiled dll)? The main goal is to set DataMember name, to avoid ugly property names for generated proxies. I think, I am looking for…
Anton Moiseev
  • 2,834
  • 4
  • 24
  • 30
2
votes
3 answers

Generating class datamembers from a Vector

Please consider this C++ question: #include #include #include using namespace std; class ParseURL{ private: int qualify; // 0 means we qualify public: string node; string service; …
struggling_learner
  • 1,214
  • 15
  • 29
2
votes
1 answer

Why can't I have a DataMember with `IsRequired=true` if my DataContract is `IsReference=true`

I have a class, ClassA which has a property which contains types of ClassB which has a field which is of Type ClassA. When I tried to serialize this via WCF I got an exception due to the recursive nature of this. The solution was to add…
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
2
votes
3 answers

Child list for field " " cannot be created

I have the following set of codes for adding values to my DataGridView through DataTable as my datasource. However, it keeps on giving me the error "Child list for field tbl_main cannot be created". Anybody can help me identify the problem?…
Amore
  • 101
  • 3
  • 11
2
votes
2 answers

C# enum DataMember changes its value in WCF

I have the following code snippet [DataMember] public StateEnum DeviceState { get { return _deviceState; } set { if (IsArmed) { …
nafarkash
  • 359
  • 6
  • 24
2
votes
1 answer

JSON.NET Deserialize interface to attribute name

I have a JSON string e.g. { "first_name": "Paul" "company": { "company_name": "Microsoft" } } and my class is in the following structure [DataContract] class User { [DataMember(Name = "first_name")] public string FirstName { get; set;…
Carl Thomas
  • 3,605
  • 6
  • 38
  • 50
2
votes
3 answers

Is it necessary to declare attribute [DataMember(Order=n)] on public method?

In my solution, I have created public class to store value and already declare [DataContract/DataMember] attribute. For example, [DataContract] public class MeterSizeInfo { string _meterSizeId; [DataMember(Order = 1)] public string…
tong
  • 259
  • 5
  • 23
2
votes
1 answer

How to print data member's address(in class offset) with "cout"

I have a class below: class A { public: double a; float b; double c; }; I want to print data member offset in class, than I use: double A::* pm = &A::a; cout << *(int *)&pm << endl; It works well and print '0', but I don't want to use…
Carl Chen
  • 21
  • 2
2
votes
1 answer

DataContractSerializer to deserialize a Member without namespace?

I need to deserialize this xml (that I can't change): string I made this class: [DataContract(Name = "a", Namespace = "http://example.com")] public class A { [DataMember(Name = "b", Order…
Cœur
  • 37,241
  • 25
  • 195
  • 267
2
votes
1 answer

.Net Represent xml in class without xsd

How would I represent something like this 12452 good stuff 5 for use in my WCF service? Not sure how to define the multiple attributes…
Chris Klepeis
  • 9,783
  • 16
  • 83
  • 149
2
votes
0 answers

Using DataContract on a subclass and not parent class

I am trying to implement a json serializer on some of my classes. These classes inherit from some legacy code that I cannot change and do not have any references to DataContract or DataMember. Is it possible for me to only have the subclass be…
ccipriano
  • 310
  • 1
  • 9
2
votes
0 answers

Corrupted double-linked list error

I am working on a Qt/OpenGL gui that makes physics animation. I try to do rotation with mousePressEvent and mouseMoveEvent functions. For this, I try to add QPoint lasPos data member for mouse positions. But I don't know why I get the following…
user1773603