Jump to content

How to pass a sc_event as parameter without pointers?


SiGa

Recommended Posts

I have a class with an sc_event which should be readable and writeable through getter and setter methods.

class IntWithEvent {
 private:
	sc_event _ev_wr;
	sc_event _ev_trigger;
public:
 	const sc_event& get_write_event() const {
		return _ev_wr;
	}
  
 	const sc_event& get_trigger_event() const {
		return _ev_trigger;
	}
  
	void set_trigger_event(sc_event &ev) const {
		_ev_trigger = ev; // E0349	no operator "=" matches these operands
	}
}

 

Writing the getters was no problem. However the setter throws me an error of no matching assignment operator. 

Do I need to store a pointer to a sc_event and then set the pointer to the address of the parameter? It doesn't give me compile errors like this.

class IntWithEvent {
 private:
	sc_event _ev_wr;
	sc_event *_ev_trigger;
public:
 	const sc_event& get_write_event() const {
		return _ev_wr;
	}
  
 	const sc_event& get_trigger_event() const {
		return *_ev_trigger;
	}
  
	void set_trigger_event(sc_event *ev) {
		_ev_trigger = ev; 
	}
}

I was taught to avoid pointers where I can. Is there a way to avoid the pointers?

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...