LinuxQuestions.org
Review your favorite Linux distribution.
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, 11:16 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix, MX
Posts: 327

Rep: Reputation: Disabled
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 11:42 PM.
 
Old 10-10-2022, 11:41 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,387
Blog Entries: 1

Rep: Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:30 PM
message sending failed : Error[22 ] invalid argument .....but each and every argument rakeshranjanjha Linux - Software 2 01-08-2008 12:22 AM
can i modify int 80 vector to a user-defined vector qqrilxk Linux - Security 1 03-03-2005 09:46 PM
Merge Two Vector values into new vector ArulPrabhuT Programming 2 09-23-2004 11:18 AM
Miseries at install from HDD&floppies, with vector ISO& how to boot with vector linux prctom VectorLinux 9 06-29-2004 06:27 AM

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

All times are GMT -5. The time now is 07:14 PM.

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