LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-10-2022, 10:16 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
Anyone explain on initializing each vector argument ?


One outright understand definitely each vector argument in initialization (v) ?

Code:
enum Mon : int {
A = 5,
B, C
};

struct M {

explicit M(Mon m, Mon n) : v{ 1, m } {}
vector<Mon> v;
};


int main(){
Mon m=A, n=B;

M moo{m, n};

}
the first; 1 ?

Thanks before

Last edited by BudiKusasi; 10-10-2022 at 10:42 PM.
 
Old 10-10-2022, 10:41 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,871
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
It is suboptimal as parameter `n` is never used. Another attempt:
Code:
vector<Mon> *genMonVect(Mon m, Mon n) {
  vector<Mon> *v= new vector<Mon>(m-n+1);
  for (Mon i=m; i<=n; ++i) v->push_back(i);
  return v;
}

int main() {
    vector<Mon> *v= genMonVect(Mon::B, Mon::C);
    ...
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Tropic of Vector – a blog devoted to Vector Linux Light, plus the Vector Linux LXer Syndicated Linux News 0 09-17-2009 01:30 PM
message sending failed : Error[22 ] invalid argument .....but each and every argument rakeshranjanjha Linux - Software 2 01-07-2008 11:22 PM
can i modify int 80 vector to a user-defined vector qqrilxk Linux - Security 1 03-03-2005 08:46 PM
Merge Two Vector values into new vector ArulPrabhuT Programming 2 09-23-2004 10:18 AM
Miseries at install from HDD&floppies, with vector ISO& how to boot with vector linux prctom VectorLinux 9 06-29-2004 05:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration