Questions tagged [class-members]

This tag refers to members of a class in object-oriented language. These are fields, constructors, destructors, methods and, usually in higher-level languages, properties and events.

refers to members of a class in object-oriented language. These are fields, constructors, destructors, methods and, usually in higher-level languages, properties and events.

186 questions
0
votes
3 answers

Use of undeclared identifier in a class

I'm building a class where the constructor for the class takes a string representing a date. The constructor should assign the month, day and year into the appropriate data members of the class. I've written something quite basic so far that assumes…
Mars
  • 4,677
  • 8
  • 43
  • 65
0
votes
0 answers

C++ segmentation fault: getting member pointer

My class contain pointer to the histogram object (from ROOT framework). I would like to after filled return it, but segmentation fault is occurring. // header class PedestalSubstractorModel { TH2D* histo; public : …
user1877600
  • 627
  • 1
  • 9
  • 26
0
votes
1 answer

How to pass a member function to a function used in another member function?

I found something about my problem, but I don't already understand very well. I need to do something like this: class T { double a; public: double b; void setT(double par) { a = par; } double funct(double par1) …
The Newbie Toad
  • 186
  • 2
  • 15
0
votes
1 answer

passing user defined member function with mem_fun_ref()

i got through with passing normal methods and functors as arguments, how ever i got stuck with passing member variables. #include #include #include #include #include using namespace std; class…
Maurice Rodriguez
  • 663
  • 2
  • 7
  • 17
0
votes
1 answer

Google Test (gtest): ASSERT_PREDx and class member functions

Ok, so I'm using gtest for unit testing, and I've got something I want to do: class A { /* Private members */ public: bool function_to_test(int index); } In the test function, I'd like to use: A testEntity; const int b =…
Doug
  • 775
  • 2
  • 11
  • 24
0
votes
1 answer

Using Linq , Reflection , lambda expressions to systematically add SqlParameters into SqlParameterCollection

public class SomeClass { public SqlParameterCollection SPPC; public SomeClass(someType somePrameter) { ....... SqlParameters assignmet with someParameter goes here ....... ... …
LoneXcoder
  • 2,121
  • 6
  • 38
  • 76
0
votes
1 answer

Eigen's Map<> as a class member

I'm trying to have a class that contains array but have an interface to them through eigen. class A { public: array xa; Map> x; A() : x(xa.data(),xa.size()) {} }; this doesn't work : A a; a.xa[0] = 0.12; cout <<…
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
0
votes
1 answer

Sort list of class elements

I have a record class like this : public class RecordInfo { public String CDate; public String Patient_ID; public Color Zone; public String Fname; public String Lname; public Int64 ImgSize; public String ImagePrefix; …
R.Vector
  • 1,669
  • 9
  • 33
  • 41
0
votes
2 answers

Is this name lookup in dependent base class with VC++ 2010 non-standard?

The code below does not compile on Ideone or Codepad, yielding errors like: 'X' was not declared in this scope but it does on VC++ 2010: #include #include template struct Base { …
TemplateRex
  • 69,038
  • 19
  • 164
  • 304
0
votes
3 answers

Do class member reference variables have in-built "const-correctness"?

struct A { int &r; A (int &i) : r(i) {} void foo () const { r = 5; // <--- ok } }; The compiler doesn't generate any error at r = 5;. Does it mean that &r is already const-correct being a reference (logical equivalent of int* const) ?…
iammilind
  • 68,093
  • 33
  • 169
  • 336
0
votes
3 answers

Should I use Func in place of a private method?

I'm posting it here and not code review because I want to know if the executing program can behave differently because of this (possibly something subtle). Is a private method: private int Foo() { return Bar().Bat(); } Any…
Aaron Anodide
  • 16,906
  • 15
  • 62
  • 121
-1
votes
1 answer

Unable to use string as class atribute (see the Update 4)

Take this class as example: #include using namespace std; class One { private: string * text; public: One(); ~One(); void setText(string value); string uppercase(); string lowercase(); string inverted(); }; its…
Kleber Mota
  • 8,521
  • 31
  • 94
  • 188
-1
votes
1 answer

Trouble using std::make_unique with member variable of class

I have not used std::make_unique before, and code inspection encouraged me to do it. If I use this, it does not display errors: auto x = make_unique(); But when I try it with my class member variable…
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
-1
votes
1 answer

Why does this C++ data member declaration contain an ampersand?

I am a novice trying to understand some C++ code in the open-source game Simutrans. Specifically, this declaration (line 79 in this header file): class env_t { public: /// if we are the server, we are at this port ///…
Matthew
  • 156
  • 1
  • 9
-1
votes
1 answer

Class member is null in another method returning value from the first one

I am having trouble to understand why the class member cannot carry forward the assigned/return value from one method to another. How exactly I should use the class member/s so it will be available throughout the class and…
Code Lover
  • 8,099
  • 20
  • 84
  • 154
1 2 3
12
13