replaceAll method in java

I have a problem about using replaceAll method in my java app. I think there is a compile error, and the code is : public static void main(String[] args) { String Str = " Welcome to Itpro.com please visit programming.itpro.com"; System.out.println(Str.replaceAll(".com", ".net")); } } and output is : We.nete to Itpro.net please visit programming.itpro.net welcome… Read More replaceAll method in java

C++ How to create a constant pointer to a function?

I want to have a class with a constant pointer to a function as a member. However, I’m instead creating functions with constant return values (a strange feature I just run into while debugging). The troublesome declarations are: // … template<typename T, typename ComparableValue> class TimestampedValueHeap { public: TimestampedValueHeap( const ComparableValue (*)(const T&), const big_unsigned… Read More C++ How to create a constant pointer to a function?

Compilation error – defining a concrete implementation of templated abstract class

I have an abstract class in my header file: template <class T> class IRepository { public: virtual bool SaveData(Result<T> &r) = 0; //virtual Result<T> & GetData()const = 0; virtual ~IRepository() {} }; I inherit it in the header file itself: template <class T> class Repo1 :public IRepository<T> { public: bool SaveData(Result<T> &r)override; //Result<T> & GetData()… Read More Compilation error – defining a concrete implementation of templated abstract class

Java Method receive generic list and returns <capture of ?>

I’m trying to filter a List of objects that implements a Interface. And I trying to create a generic method for all the classes. Something like: interface SomeInterface { String getFlag(); } class SomeObject implements SomeInterface { public String getFlag() { return "X"; } } List<SomeObject> someObjectList = new ArrayList<>(); // Compilation error here List<SomeObject>… Read More Java Method receive generic list and returns <capture of ?>

How can change the value of a member of a base class?

I have three classes: class Operation{ public: virtual bool execute(const Solution& sol, Solution& newSol) = 0; pair<int, int> pair_routes; }; class OperationR : public Operation{ public: OperationR(){}; bool execute(const Solution& sol, Solution& newSol); pair<int, int> pair_routes; }; class OperationD : public Operation{ public: OperationD(){}; bool execute(const Solution& sol, Solution& newSol); pair<int, int> pair_routes; }; The… Read More How can change the value of a member of a base class?

indexing an element from a volatile struct doesn't work in C++

I have this code: typedef struct { int test; } SensorData_t; volatile SensorData_t sensorData[10]; SensorData_t getNextSensorData(int i) { SensorData_t data = sensorData[i]; return data; } int main(int argc, char** argv) { } It compiles with gcc version 8.3, but not with g++. Error message: main.c: In function ‘SensorData_t getNextSensorData(int)’: main.c:8:34: error: no matching function for… Read More indexing an element from a volatile struct doesn't work in C++