Step Return does not work properly [message #1805367] |
Fri, 12 April 2019 16:44 |
Ahmad Shahba Messages: 2 Registered: April 2019 |
Junior Member |
|
|
I have written a very simple C++ project that I am trying to debug. I am seeing a strange behavior from Step Return in debug mode. Here is the code:
main.cpp file
#include <iostream>
#include "Foo_bar.h"
#include "Point.h"
using namespace std;
int main(){
Point p1(1, 2);
p1.printPointInfo(cout);
Point p2 = Foo_bar(p1);
p2.printPointInfo(cout);
cout << "we are done " << endl;
}
Point.h file
#ifndef POINT_H_
#define POINT_H_
#include <iostream>
class Point{
public:
// counter
static std::size_t counter;
// Default constructor
Point() = default;
// Regular constructor
Point(const double &x_, const double &y_) : x(x_), y(y_) {};
// Copy-constructor
Point(const Point &rhs);
// Print contents of the Point
void printPointInfo(std::ostream &os) const;
private:
double x = 0, y = 0;
};
#endif /* POINT_H_ */
Point.cpp file
#include "Point.h"
std::size_t Point::counter = 0;
Point::Point(const Point &rhs){
std::cout << "copy-constructor is called:" << (++counter) << std::endl;
x = rhs.x;
y = rhs.y;
}
void Point::printPointInfo(std::ostream &os) const {
os << x << " " << y << std::endl;
}
Foo_bar.h file
#ifndef FOO_BAR_H_
#define FOO_BAR_H_
#include "Point.h"
Point Foo_bar(Point arg);
#endif /* FOO_BAR_H_ */
Foo_bar.cpp file
#include "Foo_bar.h"
Point Foo_bar(Point arg)
{
Point local = arg;
return local;
}
As you can see, Foo_bar is called by main. I set a breakpoint at the first line of Foo_bar. The code stops on this line. When I hit Step Return, Eclipse exits Foo_bar and continues to execute the rest of the code. I expected a different behavior. I expected Eclipse to exit Foo_bar and goes to the "main" and wait when Step Return is performed.
Please let me know if I am missing anything here. BTW, I am using Eclipse IDE for C/C++ Developers, Version: 2019-03 (4.11.0)
-
Attachment: Foo_bar.h
(Size: 0.12KB, Downloaded 55 times) -
Attachment: Foo_bar.cpp
(Size: 0.10KB, Downloaded 72 times) -
Attachment: main.cpp
(Size: 0.24KB, Downloaded 75 times) -
Attachment: Point.cpp
(Size: 0.29KB, Downloaded 56 times) -
Attachment: Point.h
(Size: 0.46KB, Downloaded 80 times)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03497 seconds