Questions tagged [member-functions]

A function declared and/or defined within a class.

A member function is a procedure that whose signature is declared inside a class. This function takes an implicit argument of the same type as the containing class and is only accessible via an object of that type. When the function is static, no implicit argument is needed, but the function must be invoked via the class' scope. In contrast, a free-function does not have an implicit argument of the class type nor is invoked via a class scope.

626 questions
-1
votes
1 answer

Call to a member function send() on string

I got the call to a member function send() on string. I tried to read other questions w ith this title but none of them seems to be my case. This is how my function looks like: public function sendProjectTeam($clientId) { $clientEmail =…
Code Worm
  • 313
  • 1
  • 4
  • 16
-1
votes
1 answer

which is better? adding a parameter or using a member function

void recursiveFunction(container_t container) { size_t max = container.size(); ... } This is my first implementation. void recursiveFunction(container_t container, const size_t max) { ... } This is my second implementation. These…
박민철
  • 23
  • 2
-1
votes
4 answers

which one is the best way to access member functions in derived class of base class?

This is the one way to access the member function of base class with help of scope resolution operator. But member functions have same names display(). #include using namespace std; class person{ public: int age; void…
-1
votes
3 answers

How to create a class which uses member functions defined in another class C++

I'm new to object oriented programming and am struggling a bit with how best to write classes. I am trying to abstract the idea of sorting to objects that are not just lists of numbers. I have an abstract base class, SortableContainer, which…
Jamgreg
  • 15
-1
votes
1 answer

where is a member function allocated memory in c++ and how often?

where does a member function of class gets its memory allocated? Is stack frame the answer for it? And does it gets allocated whenever we call the member function? Is that like whenever we call a member function using an object it gets…
-1
votes
1 answer

oracle how to transfer SQL into member function

one of my assignment question is: The method AvgReviewScore() returns the average review score for an album excluding scores from anonymous reviewers, i.e. reviews with null REVIEWER_NAME. So firstly i wrote SQL: (This is oriented database…
Zeng Ryan
  • 1
  • 1
-1
votes
1 answer

Designing two equivalent member functions returning a const and a non-const pointer-to-member, respectively

I have a class A and a member function f, that returns a pointer to some contents of the instance int* A::f() { // common code ... return &(this->some_container[some_index]) } Now, I need an analogue function, which only returns a const…
flonk
  • 43
  • 1
  • 4
-1
votes
5 answers

C++ Pointer can call Member Function without Object

Amazingly people may call it feature but I use to say it another bug of C++ that we can call member function through pointer without assigning any object. See following example: class A{ public: virtual void f1(){cout<<"f1\n";} …
-1
votes
1 answer

by overloading [], how to assign values to the second array member in a class?

I am a learner. I am working on operator overloading. I am writing a code that has the below items: 1. A class with two member arrays 2. Overloaded [] function If my class has just one array member, I can overloaded [] to assign the values. But what…
-1
votes
1 answer

Const operator in member function (Why can be in two different parts)?

We can find: 1) const char *get() { return str; } 2) int get() const { return A; } What is the differences of "const" in this two different parts of the function?
Pablo De Luca
  • 795
  • 3
  • 15
  • 29
-1
votes
3 answers

Is it safe to assign reference variable,which is of method level to Class level reference variable?

If i have following code for a Java program class Dotcom{ private int positions[];// position is reference variable at class level //some other instance variables // suppose here we have setter for initialising "positions" public…
OldSchool
  • 2,123
  • 4
  • 23
  • 45
-1
votes
1 answer

It there a need to declare const instance of a class with all attributes const?

This is a followup to Does a class with all attributes const need to have member function declared const as well?. So I've a class PermutationGroup whose all attribute are const. The compiler still make the distinction between const and non-const…
hivert
  • 10,579
  • 3
  • 31
  • 56
-1
votes
6 answers

What is a member function in c++?, does it contain a body?, is it defined in the .h or .cpp file?

I'm new in c++. I'm required to define member functions. I am more familiar with java. I actually confused by the term "member function". Do we have to define it in the header .h file or the .cpp file?
MswatiLomnyama
  • 1,326
  • 2
  • 13
  • 19
-1
votes
2 answers

How do I use this member, declared in a header, as a function?

These are some parts of my crawler header file. I cannot make changes to this header file. private: int top_position; // The maximum position of the throttle bool left_reverse; // true if left direction is reverse bool…
-1
votes
2 answers

Oracle ORA-01422: exact fetch returns more than requested number of rows

I am trying to create a member function that returns the member names of expired members. My select query works outside of the member function and this member function compiles with no problems but when I call the function I get this…